Workflows
Workflows define product behavior and business logic. Each workflow specifies its capability, authorization, inputs/outputs, execution steps, state transitions, and effects.
Full Workflow Example
billing.prd
workflow create_invoice {
capability: invoicing
authorization {
accountant: [invoice.create]
}
input {
customer: crm.customer
}
reads { crm.customer }
writes { invoice }
rules { customer_must_exist }
steps {
call validate_customer
decide customer_valid {
yes: call create_invoice_record
no: fail invalid_customer
}
}
transitions {
invoice.status: draft -> issued
}
effects {
audit "Invoice created"
emit invoice_created
}
returns {
ok: invoice
error: invoice_error
}
}Workflow Sections
- capability - Domain capability classification
- authorization - Actor-to-permission mapping (e.g.,
accountant: [invoice.create]) - input / returns - Typed contracts for data flow
- reads / writes - Data access declarations
- rules - Business rule references
- steps - Execution steps:
call,decide,fail - transitions - Entity state changes
- effects - Side effects:
audit,notify,emit
Step Types
call- Invoke a function or servicedecide- Conditional branching withyes/nobranchesfail- Abort workflow with an error
Event-Triggered Workflows
Workflows can be triggered by events or schedules using the on: prefix:
workflow on:invoice_overdue {
capability: billing
steps {
call send_overdue_reminder
call escalate_to_manager
}
effects {
notify customer "Invoice overdue"
}
}