đź”— Projection Contracts

How DomainForge™ DSL maps to target systems.


Overview

The Projection Engine transforms DomainForge™ DSL models into multiple target formats, maintaining semantic isomorphism across all projections.

1
2
3
4
5
6
DomainForge™ DSL
     │
     ├──→ CALM (Architecture)
     ├──→ Knowledge Graph (RDF)
     ├──→ SBVR (Business Rules)
     └──→ SHACL (Validation Shapes)

DSL → CALM Mapping

DSL Concept CALM Construct Attributes
Entity Node type, namespace, conceptId
Resource Node unit, dimension
Flow Relationship type=”flow”, resource, quantity, unit
Policy Control kind, modality, priority

Example

DSL:

Entity "Warehouse.A" in logistics
Flow "Delivery" from "Plant.B" to "Warehouse.A" quantity 200 "kg"

CALM:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
  "nodes": [
    { "id": "warehouse-a", "type": "Entity", "namespace": "logistics" },
    { "id": "plant-b", "type": "Entity", "namespace": "manufacturing" }
  ],
  "relationships": [
    {
      "id": "delivery",
      "type": "flow",
      "source": "plant-b",
      "target": "warehouse-a",
      "properties": {
        "resource": "Steel",
        "quantity": 200,
        "unit": "kg"
      }
    }
  ]
}

DSL → Knowledge Graph (RDF)

DSL Concept RDF Class Properties
Entity sea:Entity rdfs:label, sea:inContext
Resource sea:Resource sea:unit, sea:dimension
Flow sea:Flow sea:from, sea:to, sea:quantity
Policy sea:Rule sea:kind, sea:modality, sea:priority

Example

DSL:

Entity "Warehouse.A" in logistics
Resource "Steel" unit "kg" in manufacturing

RDF (Turtle):

1
2
3
4
5
6
7
8
9
10
11
12
13
@prefix sea: <http://sea-forge.com/schema/core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<http://sea-forge.com/entity/warehouse-a>
    a sea:Entity ;
    rdfs:label "Warehouse.A" ;
    sea:inContext <http://sea-forge.com/context/logistics> .

<http://sea-forge.com/resource/steel>
    a sea:Resource ;
    rdfs:label "Steel" ;
    sea:unit "kg" ;
    sea:inContext <http://sea-forge.com/context/manufacturing> .

DSL → SBVR Mapping

DSL Quantifier SBVR Form
forall Universal quantification
exists Existential quantification
exists_unique Exactly one quantification
Obligation “It is obligatory that…”
Prohibition “It is prohibited that…”
Permission “It is permitted that…”

Example

DSL:

Policy unique_names per Constraint Obligation priority 5 as:
  forall e1 in entities:
    forall e2 in entities:
      (e1 != e2) implies (e1.name != e2.name)

SBVR:

1
It is obligatory that each entity has a name that is different from the name of every other entity.

DSL → SHACL Shapes

Policies generate SHACL shapes for graph validation:

DSL:

Policy vendor_limit per Constraint Obligation priority 5 as:
  sum(f in flows where f.to.name = "Vendor.X": f.quantity as "USD") <= 5000 "USD"

SHACL:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
ex:VendorLimitShape
    a sh:NodeShape ;
    sh:targetClass sea:Flow ;
    sh:property [
        sh:path sea:to ;
        sh:hasValue <http://sea-forge.com/entity/vendor-x> ;
    ] ;
    sh:sparql [
        sh:message "Vendor payment limit exceeded" ;
        sh:prefixes ex: ;
        sh:select """
            SELECT $this (SUM(?qty) AS ?total)
            WHERE {
                ?flow sea:to <http://sea-forge.com/entity/vendor-x> ;
                      sea:quantity ?qty .
            }
            GROUP BY $this
            HAVING (SUM(?qty) > 5000)
        """ ;
    ] .

Projection Commands

1
2
3
4
5
6
7
8
# Generate all projections
sea project models/ --calm --kg --sbvr --shacl

# Generate specific projection
sea project models/finance.sea --kg --output generated/

# Validate projections match source
sea validate --projection-check

Drift Detection

1
2
3
4
5
6
7
# Compare current projections against main branch
sea diff --against main --fail-on-breaking

# Output shows semantic changes
+ Added: Entity "NewWarehouse"
~ Modified: Flow "Delivery" quantity 200 → 300
- Removed: Policy "old_limit"