Register Customer

This example models customer registration as a capability. It names the initiating actor, input shape, possible outcomes, a rule, ordered effects, and an emitted event.

register-customer.dcl
language dcl 0.9

actor Customer is human

effect PersistRegistration is persistence
effect SendVerificationMessage is notification

shape RegistrationInput {
  email: Email required
  acceptedTerms: Boolean required
}

event VerificationMessageSent is {
  email: Email required
}

capability RegisterCustomer {
  intent RegistrationInput from Customer

  outcomes {
    RegistrationAccepted
    TermsRejected
    VerificationDeferred
  }

  rule TermsAccepted: input.acceptedTerms is true

  effects {
    PersistRegistration
    SendVerificationMessage after PersistRegistration
  }

  events {
    emits VerificationMessageSent
  }

  when {
    TermsAccepted violated then TermsRejected
    SendVerificationMessage unresolved then VerificationDeferred
    otherwise then RegistrationAccepted
  }
}

Open in Playground

What It Says

A customer provides registration intent. The capability may accept the registration, reject it because terms were not accepted, or defer verification if the verification message effect cannot be resolved.

Expected Outcomes

  • RegistrationAccepted when the rule holds and effects resolve.
  • TermsRejected when accepted terms are not present.
  • VerificationDeferred when the message effect is unresolved.

Concepts Demonstrated

  • Capability-first modeling.
  • Intent sourced from an actor and validated by a shape.
  • Explicit outcomes for success, rejection, and deferral.
  • Effect ordering with after.
  • Event emission as a declared capability responsibility.