# ReopenPipelineItem

## Permission Scope

item

## Overview

Reopens a CLOSED item by setting lifecycle back to OPEN. The item remains in its current stage. After reopening, the item can be moved to another stage via MovePipelineItem.

## Business Rules

- PipelineItem must exist
- PipelineItem must be in CLOSED lifecycle
- PipelineItem lifecycle changes to OPEN
- No stage transition is created (item stays in same stage)
- A [PipelineItemChange](../model/PipelineItemChange.md) row is appended (`CLOSED → OPEN`)

## Process Flow

```mermaid
flowchart TD
    A[Receive reopenPipelineItem input] --> B{PipelineItem exists?}
    B -->|No| C[Return ITEM_NOT_FOUND]
    B -->|Yes| D{PipelineItem CLOSED?}
    D -->|No| E[Return ITEM_NOT_CLOSED]
    D -->|Yes| F[Set item lifecycle to OPEN]
    F --> H[Append PipelineItemChange row - LIFECYCLE]
    H --> G[Return reopened PipelineItem]
```

## External Dependencies

- None

## Error Scenarios

- **ITEM_NOT_FOUND**: Specified item ID does not exist
- **ITEM_NOT_CLOSED**: PipelineItem is not in CLOSED lifecycle

## Test Cases

- reopening a CLOSED item succeeds and sets lifecycle to OPEN
- item remains in current stage after reopen
- writes a PipelineItemChange recording CLOSED → OPEN
- does not create a PipelineStageTransition record
- returns error when item not found
- returns error when reopening an OPEN item (ITEM_NOT_CLOSED)
- returns error when reopening a DRAFT item (ITEM_NOT_CLOSED)
