Attributes & Design Contracts (#[...])
Rust-inspired governance tags, operational resilience inlines, and statically checked pre/post/invariant contracts.
Dhi separates visual presentation ([label: "...", gap: 40]) from non-visual semantic metadata (#[attribute_name(...)]). All built-in attributes belong to a closed v1 registry—unknown attribute names emit E260 and invalid target placement emits E262.
Semantic #[...] vs. Visual [...]
Stacking governance and resilience attributes above a declaration
#[owner(team: "checkout-squad", oncall: "slack:#checkout-alerts")]
#[security(tier: "pci-dss", auth: "mtls", pii: true)]
lifeline service @VaultSvc [label: "Card Vault"];Category A: Governance & Metadata
| Attribute | Key Parameters | Purpose |
|---|---|---|
| #[owner(...)] | team (req), oncall, repo | Assign engineering ownership and on-call routing to lifelines, frames, or classes |
| #[security(...)] | tier (req), auth, pii | Mark security boundaries ("public", "pci-dss", "hipaa") and PII handling |
| #[deprecated(...)] | since (req), replace_with, note | Flag retiring elements (emits W062 on references) |
| #[doc("...")] | Positional prose string | Attach documentation/ADR links (/// comments desugar directly to #[doc]) |
| #[env(...)] | runtime, min_version | Capture deployment runtime constraints ("k8s", "embedded") |
| #[tag(...)] | Arbitrary key: value pairs | General-purpose architectural categorization |
Category B: Operational Resilience
| Attribute | Key Parameters | Valid Targets |
|---|---|---|
| #[retry(...)] | max (req), backoff, on | Message arrows (->), async calls, transitions |
| #[timeout("...")] | Duration string (e.g. "150ms") | Message arrows, exec specs, transitions, actions |
| #[circuit_breaker(...)] | threshold, reset, fallback | Message arrows, exec specs |
| #[rate_limit(...)] | max, window | Lifelines, exec specs, message arrows, states |
| #[idempotent(...)] | key (e.g. "header:X-Request-Id") | Message arrows, exec specs, transition triggers |
| #[trace(...)] | span (req), sample_rate | Exec specs, message arrows, transitions, actions |
| #[transaction(...)] | isolation, rollback_on_fail | Exec spec blocks, critical / par blocks |
Category C: Design Contracts & Class Binding
#[pre(...)], #[post(...)], and #[invariant(...)] express formal design contracts. When linked to a Class Diagram (via link class or typed lifelines), unquoted boolean expressions resolve statically against class fields (E266 type mismatch, E267 unknown member); opaque string fallbacks like #[pre("customCheck()")] are also supported.
Statically checked contracts bound to a linked Order class
uml::state_machine "OrderLifecycle" {
schema {
link class Order as order;
#[invariant(order.totalAmount >= 0.0)]
state @Draft;
state @AwaitingPayment;
state @Paid;
}
flow {
Draft on SubmitOrder {
#[pre(order.itemCount > 0 && order.totalAmount > 0.0)]
if order.itemCount > 0 -> AwaitingPayment;
}
AwaitingPayment on PaymentCaptured {
#[post(order.isPaid == true)]
-> Paid;
}
}
}