Core Language

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

AttributeKey ParametersPurpose
#[owner(...)]team (req), oncall, repoAssign engineering ownership and on-call routing to lifelines, frames, or classes
#[security(...)]tier (req), auth, piiMark security boundaries ("public", "pci-dss", "hipaa") and PII handling
#[deprecated(...)]since (req), replace_with, noteFlag retiring elements (emits W062 on references)
#[doc("...")]Positional prose stringAttach documentation/ADR links (/// comments desugar directly to #[doc])
#[env(...)]runtime, min_versionCapture deployment runtime constraints ("k8s", "embedded")
#[tag(...)]Arbitrary key: value pairsGeneral-purpose architectural categorization

Category B: Operational Resilience

AttributeKey ParametersValid Targets
#[retry(...)]max (req), backoff, onMessage arrows (->), async calls, transitions
#[timeout("...")]Duration string (e.g. "150ms")Message arrows, exec specs, transitions, actions
#[circuit_breaker(...)]threshold, reset, fallbackMessage arrows, exec specs
#[rate_limit(...)]max, windowLifelines, exec specs, message arrows, states
#[idempotent(...)]key (e.g. "header:X-Request-Id")Message arrows, exec specs, transition triggers
#[trace(...)]span (req), sample_rateExec specs, message arrows, transitions, actions
#[transaction(...)]isolation, rollback_on_failExec 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;
    }
  }
}