# Task: Execute multi-level approval workflow

## Feature

`docs/FEATURES/approval-workflow.md`

## Goal

Use configured multi-level approval steps when content enters approval and when approvers record decisions.

## Context

Tasks 005 and 006 make multi-level approval configurable. This task makes that configuration affect runtime approval behavior.

## Scope

- Create or update the approval workflow runtime model so a `ContentItem` has at most one active approval workflow instance.
- Instantiate ordered approval steps from workspace configuration when content enters `In approval`.
- Track step status as `Pending` or `Approved`.
- Allow approval only on the current pending step.
- Require each step's configured approver count before the step becomes approved.
- Advance to the next step after the current step is approved.
- Move content to `Approved` or `Scheduled` after the final step completes, following existing workspace options.
- Preserve approval history.
- Notify current step approvers when a step becomes current.
- Notify publish-capable users when final approval completes.
- Keep the existing single-step `Optional` and `Required` flows working.

## Constraints

- Do not implement configuration recalculation for already-active workflows in this task unless the task is explicitly expanded.
- Do not implement reminders, comments, mentions, reopening, or magic links in this task.
- Do not delete previous approval history.
- Preserve workspace scoping and access checks.

## Likely Files

- `backend/src/Socialize.Api/Modules/Approvals/Data/*`
- `backend/src/Socialize.Api/Modules/Approvals/Handlers/*`
- `backend/src/Socialize.Api/Modules/Approvals/Services/*`
- `backend/src/Socialize.Api/Modules/ContentItems/Handlers/*`
- `backend/src/Socialize.Api/Modules/Notifications/*`
- `backend/src/Socialize.Api/Migrations/*`
- `backend/tests/Socialize.Tests/Approvals/*`
- `frontend/src/features/content/views/ContentItemDetailView.vue`
- `frontend/src/features/reviews/*`

## Done When

- [x] Content entering approval creates a runtime approval workflow with ordered steps.
- [x] Only the current pending step can be approved.
- [x] Required approver counts are enforced.
- [x] Final approval updates content status according to workspace options.
- [x] Approval history remains available after completion.
- [x] Notifications are written for current approvers and final approval.
- [x] Backend tests cover sequencing, counts, access, and final status behavior.

## Validation Commands

```bash
dotnet build backend/Socialize.slnx
dotnet test backend/Socialize.slnx
cd frontend && npm run build
```
