# ApprovalDecision

## Description

ApprovalDecision is the immutable, append-only log of every actor-driven transition on an `ApprovalRequest`. The `decision` enum has seven values — `APPROVE`, `REJECT`, `SEND_BACK`, `DELEGATE`, `WITHDRAW`, `CANCEL`, `RESUBMIT` — and the row carries `approvalRequestId` as a required FK and `approvalStepId` as a nullable FK.

## Domain Model Definitions

### Model type

AppendOnly

### Command Definitions

- [approveApprovalStep](../command/ApproveApprovalStep.md)
- [rejectApprovalStep](../command/RejectApprovalStep.md)
- [sendBackApprovalStep](../command/SendBackApprovalStep.md)
- [delegateApprovalStep](../command/DelegateApprovalStep.md)
- [withdrawApprovalRequest](../command/WithdrawApprovalRequest.md)
- [cancelApprovalRequest](../command/CancelApprovalRequest.md)
- [resubmitApprovalRequest](../command/ResubmitApprovalRequest.md)

### Query Definitions

- [getApprovalDecisionHistory](../query/GetApprovalDecisionHistory.md)

### Models

- ApprovalDecision

### Invariants

- A row is append-only: once inserted, attempts to update or delete it are rejected
- `approvalRequestId` is required
- `approvalStepId` is set on `APPROVE`, `REJECT`, `SEND_BACK`, and `DELEGATE` rows and is null on `WITHDRAW`, `CANCEL`, and `RESUBMIT` rows
- `decidedByUserId` is required
- `delegatedToUserId` is non-null on `DELEGATE` rows and null on every other decision type
- `comment` is required and non-empty on `REJECT`, `SEND_BACK`, and `CANCEL` rows (it carries the structured reason); optional on `APPROVE`, `DELEGATE`, `WITHDRAW`, and `RESUBMIT`
- `decidedAt` is set at insert

### Relationships

- **Belongs To ApprovalRequest**: Every row references exactly one parent request via `approvalRequestId`
- **Belongs To ApprovalStep (optional)**: Step-level rows reference a parent step via `approvalStepId`; null on request-level rows
- **References User (cross-module)**: `decidedByUserId` references the actor and `delegatedToUserId` (when set) references the delegate; both target rows in `user-management` are never hard-deleted
