Multi-file Composition
DCL uses contexts to compose larger models. A context owns declarations such as actors, shapes, events, policies, effects, and capabilities. Another context may use those declarations only when it declares a dependency.
Directory Shape
project/
shared.dcl
sales.dcl Shared Context
The shared context owns the common actor, input shape, and event. Ownership matters because readers and tools can see where each language element is declared.
language dcl 0.9
context Shared {
actor Customer is human
shape SharedOrderInput {
orderId: Uuid required
customerId: Uuid required
}
event SharedOrderSubmitted is {
orderId: Uuid required
}
}
Dependent Context
The sales context declares depends on Shared, making the shared
declarations visible to the sales capability.
language dcl 0.9
context Sales {
depends on Shared
effect PersistSalesOrder is persistence
capability AcceptSalesOrder {
intent SharedOrderInput from Customer
outcomes {
SalesOrderAccepted
SalesOrderDeferred
}
effect PersistSalesOrder
observe {
event SharedOrderSubmitted count as shared_orders_submitted
outcome SalesOrderAccepted count as sales_orders_accepted
}
when {
PersistSalesOrder unresolved then SalesOrderDeferred
otherwise then SalesOrderAccepted
}
}
}
How To Compile
go run ./cmd/dcl check ../website/src/examples/context-shared.dcl ../website/src/examples/context-sales.dcl Ownership
Declarations inside context Shared belong to Shared.
Declarations inside context Sales belong to Sales.
This keeps shared vocabulary separate from domain-specific capability
ownership.
Visibility
Sales can refer to Customer,
SharedOrderInput, and SharedOrderSubmitted because
it depends on Shared. Without that dependency, those names are
not visible in the sales context.
Dependencies And Hierarchy
Dependencies should point from a more specific context to the vocabulary it needs. In this example, sales depends on shared declarations; shared does not depend on sales.
Cycle Prevention
Keep dependencies directional. If two contexts need to depend on each other, extract the common declarations into a third context and have both contexts depend on that shared owner.