Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mutations

A mutation declares a reusable permitted change. It defines abstract roles, requirements for binding those roles, temporary resource uses, and persistent transformations. Declaring a mutation does not bind entities or approve its execution.

mutation "transport-payload" {
    roles [van payload destination]

    requires {
        @van.traits.vehicle
        @payload.traits.cargo
        @destination.traits.location
        @van.properties.located_at = @payload.properties.located_at
        @destination.properties.located_at
        @van.capacities.payload_mass
        @payload.properties.mass
    }

    uses {
        reserve [@van @payload]
        observe [@destination.properties.located_at]

        occupy {
            @van.capacities.payload_mass += @payload.properties.mass
        }
    }

    transforms {
        @van.properties.located_at -> @destination.properties.located_at
        @payload.properties.located_at -> @destination.properties.located_at
    }
}

Roles

roles lists the abstract entities a mutation needs. Role names must be unique within the mutation.

roles [van payload destination]

Use @role to refer to a role. An undeclared role produces a resolver error.

Requirements

requires contains expressions that describe acceptable role bindings and required component values.

requires {
    @van.traits.vehicle
    @van.conditions.readiness = ready
    @van.properties.fuel_volume > 0 l
}

Every role component value used by observe, share, reserve, occupy, or transforms must appear somewhere in requires. The mention can be nested in a larger expression. This rule makes the mutation’s data needs explicit.

Whole-role uses such as reserve [@van] are exempt because they reserve the entity rather than one component value. References to concrete entities are also exempt from the role requirement rule.

Resource uses

uses describes temporary access while a mutation is active.

SectionCurrent representation
observeRead an entity or one component value.
shareShare an entity or one component value.
reserveReserve an entity or one component value.
occupyApply a temporary change to a component value.

The first three sections contain path lists:

uses {
    observe [@destination.properties.located_at]
    share [@vehicle.properties.telemetry]
    reserve [@vehicle @payload]
}

occupy contains changes:

uses {
    occupy {
        @vehicle.capacities.payload_mass += @payload.properties.mass
    }
}

The DSL records these use modes, but scheduling and contention behavior are not implemented by the DSL resolver.

Transformations

transforms declares persistent changes. A change target must be a component value on an entity or role reference.

OperatorParsed change
=Assign
+=Add and assign
-=Subtract and assign
*=Multiply and assign
/=Divide and assign
->Become
transforms {
    @van.properties.fuel_volume -=
        $distance * @van.properties.fuel_per_distance

    @payload.properties.located_at ->
        @destination.properties.located_at
}

The resolver preserves each operator. It does not apply the changes or prove that their values and units are compatible.