workflow RefundCustomer { input { case_id: string order_id: string customer_id: string remaining_paid: integer } grants { ai.propose_refund payments.refund payments.lookup_refund } let proposal = observe "propose-refund" ai.propose_refund { case_id: input.case_id order_id: input.order_id } let refund = validate proposal { require proposal.amount > 0 require proposal.amount <= input.remaining_paid require proposal.customer_id == input.customer_id return { refund_id: input.case_id order_id: input.order_id customer_id: proposal.customer_id amount: proposal.amount reason: proposal.reason } } action "issue-refund" payments.refund { identity refund.refund_id recovery reconcile input { refund_id: refund.refund_id order_id: refund.order_id customer_id: refund.customer_id amount: refund.amount reason: refund.reason } } }