# Pipeline Lifecycle

## Overview

Pipeline is a named container that owns an ordered set of stages. Pipelines are the unit of configuration — each pipeline defines its own stage set. A pipeline has a name, description, creator (`createdByUserId`, immutable audit metadata), and lifecycle state (ACTIVE/ARCHIVED). It also carries a free-form `pipelineType` kind identifier (name uniqueness is scoped per type), an optional `stages` template seeded at creation, and a `locked` flag for managed boards whose stage set is fixed to that template — see [Pipeline](../model/Pipeline.md) for details.

## Business Purpose

Enable teams to create distinct pipelines for different workflows. PipelineStage configurations are isolated per pipeline so changes don't affect unrelated workflows. Multiple concurrent pipelines are supported within the same app.

## Process Flow

```mermaid
flowchart TD
    A[Create Pipeline] --> B{Valid?}
    B -->|Yes| C[Save Pipeline as ACTIVE]
    B -->|No| D[Return Validation Error]
    C --> E[Pipeline Available]
    E --> F[Configure Stages]
    E --> G[Add Items]
    E --> H[Update Pipeline Name/Description]
    E --> I[Archive Pipeline]
    I --> J[Pipeline ARCHIVED]
    J --> K[No new items allowed]
```

## Scenario Patterns

- Create a "Task Board" pipeline with stages To Do, In Progress, Review, Done
- Create a second pipeline with a different set of stages tailored to its own workflow
- Archive a pipeline after migrating to a new process — existing items remain readable but no new items can be added
- Rename a pipeline to reflect updated team terminology

## Test Cases

- Creating pipeline with valid name succeeds
- Creating pipeline with empty name fails with validation error
- Archiving active pipeline succeeds and sets state to ARCHIVED
- Archiving already-archived pipeline is idempotent (no error)
- Pipeline name must be unique per pipelineType across the app

## Reference Links

- [Odoo Project Kanban](https://www.odoo.com/documentation/19.0/applications/services/project.html)
