# SPEC-EPISODE-006-COMPLETED_EPISODE_LIFECYCLE
**Updated:** 2025-10-25  
**Owner:** Test Optimization WG  
**Purpose:** Capture current test coverage for the EpisodeCompletion aggregate, associated value objects, and persistence/warning rules.

---

## Specification Snapshot

- **Scope:** Episode completion events, derived records (character growth / important scene / foreshadowing), and warning logic that guards manuscript quality thresholds.
- **Primary documents:** `specs/archive/20250913-223116/SPEC-EPISODE-012_episode_completion.md`, `specs/archive/20250913-223116/SPEC-EPISODE-013_episode_completion_entity.md`.
- **Change history:** New meta entry drafted on 2025-10-25 to unblock Phase 7c consolidation; original SPEC numbering kept pending renaming plan.

---

## Linked Test Cases (Top Coverage Sources)

| Test File | Scenario Coverage | Notes |
| --- | --- | --- |
| `tests/unit/domain/entities/test_episode_completion.py` | Aggregates EpisodeCompletion lifecycle: record creation, persistence dict structure, domain events, quality warnings. | 28 occurrences; mix of success & validation cases; co-tags with `SPEC-EPISODE-005`.
| `tests/unit/domain/test_episode_completion_domain.py` | Mirrors entity behaviours in legacy domain suite. | Duplicated scenarios with slightly different fixtures; candidate for merge after consolidation.
| `tests/unit/domain/plot_episode/entities/test_episode_completion.py` | Plot-episode coverage via wrapper module. \| 28 occurrences; re-exports core aggregate tests until plot-specific splits are needed.
| `tests/unit/domain/plot_episode/workflows/test_episode_completion_domain.py` | Workflow-oriented validations via wrapper. \| 25 occurrences; inherits domain test set and awaits plot-specific variants.
| `tests/unit/domain/value_objects/test_episode_completion_data.py` | Base value object behaviours (immutability, serialization). | 20 occurrences; duplicates exist under `plot_episode` namespace.
| `tests/unit/domain/plot_episode/value_objects/test_episode_completion_data.py` | Plot episode variants of value objects (wrapper). \| 20 occurrences; re-export shared tests while plot-specific cases are pending.

---

## Coverage Highlights

- Validation guardrails: Ensures episode number, quality score (0-100), and word count (>=0) constraints across both standard and plot-episode workflows.
- Derived record fidelity: Confirms timestamps, formatting ("第10話"), and immutability when serializing growth and scene records.
- Warning signals: Tests for low/high quality score and low/high word count warnings to surface risk conditions during publishing.
- Domain event hygiene: Verifies event emission/clear behaviours on `CompletedEpisode` aggregate.

---

## Known Gaps & Follow-ups

1. **SPEC ID 正規化:** 現行テストは `SPEC-EPISODE-005` と併用しており、新 ID (`SPEC-EPISODE-006-COMPLETED_EPISODE_LIFECYCLE`) への更新ポリシーを策定する。
2. **重複スイート統合:** 同一シナリオを扱う `tests/unit/domain/...` と `tests/unit/domain/plot_episode/...` の差異を棚卸しし、片側へ統合する。（Phase7b の分割計画と連動）
3. **仕様リンク整備:** 上記アーカイブSPECの最新リビジョン確認後、要約セクションを meta に追記し、REQ トレーサビリティ (`specs/meta/REQ_SPEC_MAPPING_MATRIX.md`) と同期させる。
4. **テストログ・メトリクス:** `pytest -k "SPEC-EPISODE-006"` の最新実行ログ添付、および PASS/FAIL 比率をPhase7cレビュー資料に追加する。
