# RemoveAttributeValueFromProduct

## Permission Scope

product

## Overview

removeAttributeValueFromProduct removes an attribute value assignment from a product. Identified by the composite key (productId, attributeId, valueId).

## Business Rules

- Target product must exist
- On DRAFT products: assignments can be freely removed
- On ACTIVE products: removal is blocked — the axis structure is locked once activated
- On ARCHIVED products: all assignment changes are blocked
- The exact (productId, attributeId, valueId) assignment must exist

## Process Flow

```mermaid
flowchart TD
    A[Receive remove value request] --> B{Product exists?}
    B -->|No| C[Return error: PRODUCT_NOT_FOUND]
    B -->|Yes| D{Product ARCHIVED?}
    D -->|Yes| E[Return error: PRODUCT_ARCHIVED]
    D -->|No| F{Product ACTIVE?}
    F -->|Yes| G[Return error: AXIS_STRUCTURE_LOCKED]
    F -->|No| H{Assignment exists?}
    H -->|No| I[Return error: ASSIGNMENT_NOT_FOUND]
    H -->|Yes| J[Delete assignment record]
    J --> K[Return deleted assignment id]
```

## External Dependencies

- None

## Error Scenarios

- **PRODUCT_NOT_FOUND**: Specified product ID does not exist
- **PRODUCT_ARCHIVED**: Archived products do not allow any assignment changes
- **AXIS_STRUCTURE_LOCKED**: Attribute set is fixed on ACTIVE products; attribute values cannot be added or removed
- **ASSIGNMENT_NOT_FOUND**: No assignment exists for the specified product and attribute or category combination

## Test Cases

- returns error when product not found
- returns error when product is ARCHIVED
- returns error when product is ACTIVE (axis structure locked)
- returns error when assignment not found
- removes assignment successfully on DRAFT product
