# Sprint 25+: LangGraph Migration

> **Size**: XL (multi-sprint) | **Owner**: Backend | **Prerequisites**: Sprint 19, Sprint 21
> **Phase**: 5 - Platform Evolution

---

## Validation Status (2025-12-31)

### 🚫 BLOCKED — Prerequisites Not Implemented

| Prerequisite | Status | Impact |
|--------------|--------|--------|
| MCP configuration (Sprint 21) | ❌ Not implemented | Cannot configure tool sources |
| Usage events (Sprint 15 / OTel) | ❌ Not implemented | Cannot emit run metadata |
| Project scoping (Sprint 18) | ✅ Implemented | No longer blocks Sprint 21 |

**Action required**: Complete Sprint 21 (MCP Config) and Sprint 15 (Usage Events) before starting.

---

## Objective

Replace AI workflows with LangGraph after context sources/scoping exist. Enable sophisticated RAG, research, and Q&A capabilities.

---

## What Already Exists

| Asset | Location | Implication |
|-------|----------|-------------|
| Summarization service | `application/services/summarization_service.py` | ✅ Wrap target |
| RAG retrieval (Sprint 19) | ✅ `SegmentModel.embedding` + cosine_distance | Context source ready |
| MCP configuration (Sprint 21) | ❌ Not implemented | **Prerequisite missing** |
| Usage events (Sprint 15) | ❌ Not implemented | **Prerequisite missing** |

---

## Phase 1: Wrap Existing (Sprint 25)

| Task | Effort |
|------|--------|
| Wrap summarization in LangGraph graph | M |
| Keep outputs identical | S |
| Emit structured run metadata | M |
| Evaluation hooks integration | M |

---

## Phase 2: Extend Capabilities (Sprint 26+)

| Task | Effort |
|------|--------|
| Research graphs with tool-using | L |
| Multi-step Q&A with retrieval | L |
| Caching layer | M |
| Guardrails (content filtering) | M |
| Streaming responses | M |

---

## Deliverables

### Phase 1
- `src/noteflow/infrastructure/ai/graphs/summarization.py`
- Run metadata emission
- Evaluation hook wiring

### Phase 2
- `src/noteflow/infrastructure/ai/graphs/research.py`
- `src/noteflow/infrastructure/ai/graphs/qa.py`
- `src/noteflow/infrastructure/ai/cache.py`
- `src/noteflow/infrastructure/ai/guardrails.py`

---

## Post-Sprint

- Custom graph builder UI
- Graph sharing/marketplace
- Fine-tuning integration
