# UpdateChannel

## Permission Scope

marketplace

## Overview

UpdateChannel revises mutable Channel fields while the record remains editable under policy.

## Business Rules

- The Channel must exist before it can be updated.
- The Channel must remain in an editable lifecycle state.
- Channel type is required.
- Channel name must be unique enough to avoid operational ambiguity within the company.

## Process Flow

```mermaid
flowchart TD
    A[Receive update request] --> B[Load Channel]
    B --> C{Record editable?}
    C -->|No| D[Return CHANNEL_NOT_EDITABLE]
    C -->|Yes| E[Validate changed fields]
    E --> F[Persist updates]
    F --> G[Return updated Channel]
```

## External Dependencies

- [organization::GetCompany](../../../organization/docs/queries/GetCompany.md) - Validate company scope for the channel.

## Error Scenarios

- **CHANNEL_NOT_FOUND**: Referenced channel does not exist
- **CHANNEL_NOT_EDITABLE**: Channel is not in an editable lifecycle state.
- **INVALID_CHANNEL_TYPE**: Channel type is missing or unsupported.
- **DUPLICATE_CHANNEL_NAME**: A conflicting channel name already exists.

## Test Cases

- updates mutable Channel fields
- returns error when Channel does not exist
- returns error when Channel is not editable
- returns error when the resulting channel type is empty
- returns error when the updated channel name conflicts within the company
