Complete syntax guide for SEA™ DSL derived from the grammar specification.
# 1. File annotations (optional)
@namespace "domain.name"
@version "1.0.0"
@owner "team"
@profile "production"
# 2. Imports (optional)
import { Entity, Flow } from "other-module"
import * as Alias from "std:core"
# 3. Declarations (repeated)
Entity "Name" in domain
Resource "Name" units in domain
Flow "Name" from "A" to "B"
...
| Annotation | Purpose | Example |
|---|---|---|
@namespace |
Scope declarations | @namespace "com.example.sales" |
@version |
File version | @version "1.0.0" |
@owner |
Responsible team | @owner "platform-team" |
@profile |
Environment | @profile "production" |
| Annotation | Used On | Purpose |
|---|---|---|
@replaces |
Entity, Resource | Version evolution |
@changes |
Entity, Resource | Change description |
@rationale |
Policy | Business justification |
@tags |
Policy, Metric | Categorization |
@cqrs |
Flow | REQUIRED - Command/Query/Event |
@tx |
Flow (command) | Transactional boundary |
@idempotency |
Flow (command) | Idempotency key |
@outbox |
Flow (event) | Delivery mode |
@read_model |
Flow (query) | Projection reference |
import { Entity, Flow as MyFlow } from "module"
import * as Std from "std:core"
entity "Name" [v <version>] [@replaces ...] [@changes [...]] [in <domain>]
Examples:
Entity "Customer" in sales
Entity "OrderV2" v2.0.0 @replaces "Order" v1.0.0 @changes ["added status"] in orders
resource "Name" [Unit] [in <domain>]
Examples:
Resource "Money" USD in finance
Resource "Token" units in auth
Resource "Quantity" items in inventory
flow "Name" from "Source" to "Target" [quantity <number>]
REQUIRED ANNOTATIONS:
| CQRS Kind | Required Annotations |
|---|---|
command |
@cqrs, optionally @tx, @idempotency |
query |
@cqrs, optionally @read_model |
event |
@cqrs, optionally @outbox |
Examples:
Flow "CreateOrder"
@cqrs { "kind": "command" }
@tx { "transactional": true }
@idempotency { "enabled": true, "key": "orderId" }
from "Customer" to "Order" quantity 1
Flow "OrderCreated"
@cqrs { "kind": "event" }
@outbox { "mode": "required" }
from "Order" to "EventBus"
Flow "GetOrderHistory"
@cqrs { "kind": "query" }
@read_model { "name": "OrderProjection" }
from "QueryService" to "ReadStore"
policy <name>
[per <Kind> <Modality> priority <number>]
[@rationale "..."]
[@tags [...]]
[v <version>]
as: <expression>
Kinds: Constraint, Derivation, Obligation
Modalities: Obligation, Prohibition, Permission
Example:
Policy no_negative_amounts
per Constraint Prohibition priority 10
@rationale "Negative amounts break accounting"
@tags ["billing", "validation"]
as: forall f in flows: (f.quantity >= 0)
metric "Name" as: <expression>
[@refresh_interval <N> "<unit>"]
[@window <N> "<unit>"]
[@threshold <number>]
[@target <number>]
[@unit "<string>"]
[@severity "<string>"]
Example:
Metric "payment_count" as:
count(f in flows where f.resource = "Money": f.quantity)
@threshold 100
@severity "warning"
@refresh_interval 300 "seconds"
relation "Name"
subject: "Concept"
predicate: "verb phrase"
object: "Concept"
[via: flow "FlowName"]
Example:
Relation "PaidBy"
subject: "Invoice"
predicate: "is paid by"
object: "Payment"
via: flow "ProcessPayment"
instance <id> of "Entity" {
field: <expression>,
...
}
Example:
instance order123 of "Order" {
amount: 100 "USD",
status: "pending",
items: 3
}
Reference: @order123
pattern "Name" matches "<regex>"
Example:
Pattern "Email" matches "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
role "Name" [in <domain>]
Example:
Role "Admin" in auth
Role "Customer" in sales
dimension "Name"
unit "Unit" of "Dimension" factor <number> base "BaseUnit"
Example:
Dimension "Currency"
Unit "USD" of "Currency" factor 1 base "USD"
Unit "EUR" of "Currency" factor 0.92 base "USD"
Mapping "Name" for <target> {
<Primitive> "Name" -> TargetType { field: value }
}
Projection "Name" for <target> {
<Primitive> "Name" { field: value, props: {"a"->"b"} }
}
Targets: calm, kg, sbvr, protobuf, proto
| Type | Syntax | Example |
|---|---|---|
| String | "text" |
"Hello" |
| Multiline | """ text """ |
""" Long text """ |
| Number | -?digits(.digits)? |
100, 3.14, -5 |
| Boolean | true, false |
true |
| Quantity | <number> "Unit" |
100 "USD" |
| Interval | interval("start","end") |
interval("2026-01-01","2026-12-31") |
| Time | "ISO-8601" |
"2026-01-05T09:00:00Z" |
| Array | [ ... ] |
["a", "b", "c"] |
Pattern: [A-Za-z_][A-Za-z0-9_]*
Reserved Keywords: entity, resource, flow, pattern, role, relation, instance, policy, conceptchange, metric, mapping, projection, dimension, unit, import, export
Last Updated: January 2026