docs(phase-15): create phase 15 plans

This commit is contained in:
2026-03-23 22:53:07 +08:00
parent 6ea21ad565
commit 405761c6ea
4 changed files with 766 additions and 0 deletions
@@ -0,0 +1,140 @@
---
phase: 15-output-compat
plan: 00
type: execute
wave: 0
depends_on: []
files_modified:
- tests/test_pipeline/test_config.py
- tests/test_processors/test_srt.py
- tests/test_backward_compat.py
- tests/conftest.py
autonomous: true
requirements: []
must_haves:
truths:
- "测试基础设施已就绪,所有新功能测试都有占位符"
- "测试文件结构符合项目规范"
artifacts:
- path: "tests/test_pipeline/test_config.py"
provides: "配置测试基础结构"
contains: "TestEnableSemanticSegmentationField"
- path: "tests/test_processors/test_srt.py"
provides: "SRTProcessor 配置集成测试"
contains: "TestConfigIntegration"
- path: "tests/test_backward_compat.py"
provides: "向后兼容性测试"
contains: "TestBackwardCompatibility"
- path: "tests/conftest.py"
provides: "共享测试 fixtures"
contains: "temp_env_vars fixture"
key_links: []
---
<objective>
建立测试基础设施,为后续计划提供测试框架。
Purpose: 确保 Nyquist 验证合规,每个功能任务都有对应的自动化测试
Output: 测试文件结构和占位符测试
</objective>
<execution_context>
@/home/starmen1265/.claude/get-shit-done/workflows/execute-plan.md
@/home/starmen1265/.claude/get-shit-done/templates/summary.md
</execution_context>
<context>
@.planning/phases/15-output-compat/15-CONTEXT.md
@.planning/phases/15-output-compat/15-RESEARCH.md
@.planning/phases/15-output-compat/15-VALIDATION.md
@tests/test_pipeline/test_config.py
@tests/test_processors/conftest.py
</context>
<tasks>
<task type="auto">
<name>Task 1: 添加配置字段测试占位符</name>
<files>tests/test_pipeline/test_config.py</files>
<action>
在 test_config.py 中添加 TestEnableSemanticSegmentationField 测试类,包含以下测试占位符:
1. test_kbsettings_has_enable_semantic_segmentation_field - 验证字段存在
2. test_enable_semantic_segmentation_default_value - 验证默认值为 True
3. test_enable_semantic_segmentation_from_env - 验证环境变量覆盖
4. test_enable_semantic_segmentation_boolean_parsing - 验证布尔字符串解析
每个测试使用 pytest.skip("等待实现") 标记为待实现。
</action>
<verify>pytest tests/test_pipeline/test_config.py::TestEnableSemanticSegmentationField -v</verify>
<done>测试类添加成功,4个测试占位符就绪</done>
</task>
<task type="auto">
<name>Task 2: 添加 SRTProcessor 配置集成测试占位符</name>
<files>tests/test_processors/test_srt.py</files>
<action>
在 test_srt.py 中添加 TestConfigIntegration 测试类,包含以下测试占位符:
1. test_srt_processor_reads_from_kbsettings - 验证从 KBSettings 读取配置
2. test_srt_processor_constructor_overrides_config - 验证构造函数参数优先级
3. test_config_disabled_uses_rule_based - 验证禁用时使用规则分段(CONFIG-02)
4. test_output_format_with_semantic_enabled - 验证启用时输出 H2 标题(OUTPUT-01)
5. test_output_format_with_semantic_disabled - 验证禁用时输出"## 内容"(OUTPUT-03)
每个测试使用 pytest.skip("等待实现") 标记为待实现。
</action>
<verify>pytest tests/test_processors/test_srt.py::TestConfigIntegration -v</verify>
<done>测试类添加成功,5个测试占位符就绪</done>
</task>
<task type="auto">
<name>Task 3: 创建向后兼容性测试文件</name>
<files>tests/test_backward_compat.py</files>
<action>
创建新文件 tests/test_backward_compat.py,添加 TestBackwardCompatibility 测试类:
1. test_rule_based_segmentation_unchanged - 验证规则分段行为不变(CONFIG-02)
2. test_analyze_processor_unaffected - 验证 AnalyzeProcessor 不受影响(CONFIG-03)
3. test_existing_api_compatibility - 验证现有 API 调用兼容性
每个测试使用 pytest.skip("等待实现") 标记为待实现。
文件头部添加必要的导入和文档字符串。
</action>
<verify>pytest tests/test_backward_compat.py -v</verify>
<done>测试文件创建成功,3个测试占位符就绪</done>
</task>
<task type="auto">
<name>Task 4: 添加共享测试 fixtures</name>
<files>tests/conftest.py</files>
<action>
在 tests/conftest.py 中添加以下 fixtures:
1. temp_env_vars - 临时环境变量 fixture,使用 monkeypatch,测试后自动清理
2. mock_settings - Mock KBSettings fixture,用于隔离测试环境
如果 conftest.py 不存在,创建它并添加现有测试可能需要的 fixtures。
</action>
<verify>pytest tests/test_pipeline/test_config.py -k "test_get_settings" -v</verify>
<done>Fixtures 添加成功,可被其他测试引用</done>
</task>
</tasks>
<verification>
- pytest 发现所有新增测试类和测试函数
- 所有测试标记为 skip 状态(等待实现)
- 测试文件结构符合项目规范
</verification>
<success_criteria>
- Wave 0 测试基础设施就绪
- 后续计划的每个任务都有对应的测试验证
- Nyquist 验证合规(所有自动化命令都有对应测试)
</success_criteria>
<output>
Wave 0 不创建 SUMMARY.md(测试基础设施计划)
</output>
@@ -0,0 +1,161 @@
---
phase: 15-output-compat
plan: 01
type: execute
wave: 1
depends_on: []
files_modified:
- kb_workflow/pipeline/config.py
- tests/test_pipeline/test_config.py
autonomous: true
requirements:
- CONFIG-01
must_haves:
truths:
- "KBSettings 包含 enable_semantic_segmentation 字段"
- "字段默认值为 True"
- "可通过 KB_ENABLE_SEMANTIC_SEGMENTATION 环境变量覆盖"
- "Pydantic 自动解析布尔字符串(true/false, yes/no, 1/0)"
artifacts:
- path: "kb_workflow/pipeline/config.py"
provides: "KBSettings 配置类"
exports: ["enable_semantic_segmentation: bool"]
- path: "tests/test_pipeline/test_config.py"
provides: "配置测试"
contains: "TestEnableSemanticSegmentationField"
key_links:
- from: "KBSettings.__init__()"
to: "pydantic-settings BaseSettings"
via: "model_config = SettingsConfigDict(env_prefix='KB_')"
pattern: "class KBSettings\\(BaseSettings\\)"
- from: "环境变量 KB_ENABLE_SEMANTIC_SEGMENTATION"
to: "KBSettings.enable_semantic_segmentation"
via: "pydantic-settings 自动解析"
pattern: "env_prefix.*KB_"
---
<objective>
将 enable_semantic_segmentation 配置集成到 KBSettings,允许用户通过环境变量或 ~/.kb_env 文件控制 LLM 语义分段功能。
Purpose: 集中配置管理,用户无需修改代码即可启用/禁用语义分段
Output: KBSettings 新增字段,默认启用语义分段(True)
</objective>
<execution_context>
@/home/starmen1265/.claude/get-shit-done/workflows/execute-plan.md
@/home/starmen1265/.claude/get-shit-done/templates/summary.md
</execution_context>
<context>
@.planning/phases/15-output-compat/15-CONTEXT.md
@.planning/phases/15-output-compat/15-RESEARCH.md
@.planning/phases/14-robustness-cost/14-05-SUMMARY.md
@kb_workflow/pipeline/config.py
</context>
<interfaces>
<!-- KBSettings 现有结构 -->
From kb_workflow/pipeline/config.py:
```python
class KBSettings(BaseSettings):
model_config = SettingsConfigDict(
env_file=str(Path.home() / ".kb_env"),
env_file_encoding="utf-8",
env_prefix="KB_",
extra="ignore",
)
# 必需配置
base_path: str = Field(..., description="知识库根目录")
archive_path: str = Field(..., description="归档目录")
# 可选配置
git_root: str = Field(default="", description="Git 仓库根目录")
# 工作流行为配置
overwrite_archives: bool = Field(
default=False, description="覆盖已存在的归档文件(非交互模式)"
)
```
<!-- Pattern: 添加布尔配置字段 -->
```python
# 新增字段的模式
enable_semantic_segmentation: bool = Field(
default=True,
description="启用 LLM 语义分段(默认启用)"
)
```
<!-- Environment Variable Resolution -->
# ~/.kb_env 文件:
# KB_ENABLE_SEMANTIC_SEGMENTATION=true
# Pydantic 自动解析以下字符串为布尔 True:
# - "true", "True", "TRUE", "t", "yes", "y", "1"
# - False: "false", "False", "FALSE", "f", "no", "n", "0"
</interfaces>
<tasks>
<task type="auto" tdd="true">
<name>Task 1: 添加 enable_semantic_segmentation 字段到 KBSettings</name>
<files>kb_workflow/pipeline/config.py, tests/test_pipeline/test_config.py</files>
<behavior>
- Test 1: KBSettings 包含 enable_semantic_segmentation 字段,类型为 bool
- Test 2: 字段默认值为 True(未设置环境变量时)
- Test 3: 环境变量 KB_ENABLE_SEMANTIC_SEGMENTATION=false 覆盖默认值
- Test 4: 环境变量支持多种布尔表示(true, yes, 1 / false, no, 0)
</behavior>
<action>
1. 在 kb_workflow/pipeline/config.py 的 KBSettings 类中添加新字段:
```python
# 工作流行为配置
enable_semantic_segmentation: bool = Field(
default=True,
description="启用 LLM 语义分段(默认启用)"
)
```
位置:在 overwrite_archives 字段之后,保持配置分类清晰。
2. 更新 KBSettings 的 docstring,添加新字段的文档说明。
3. 实现测试(在 test_config.py 中移除 skip 标记):
- test_kbsettings_has_enable_semantic_segmentation_field
- test_enable_semantic_segmentation_default_value
- test_enable_semantic_segmentation_from_env
- test_enable_semantic_segmentation_boolean_parsing
测试模式参考现有的 test_kbsettings_has_base_path_field 等测试。
</action>
<verify>
<automated>pytest tests/test_pipeline/test_config.py::TestEnableSemanticSegmentationField -x -v</automated>
</verify>
<done>
- KBSettings.enable_semantic_segmentation 字段存在
- 默认值为 True
- 环境变量 KB_ENABLE_SEMANTIC_SEGMENTATION 可覆盖
- 4 个测试全部通过
</done>
</task>
</tasks>
<verification>
- pytest tests/test_pipeline/test_config.py::TestEnableSemanticSegmentationField 全部通过
- 字段类型为 bool,默认值为 True
- 环境变量解析正确(支持 true/false, yes/no, 1/0)
- 不影响现有配置字段
</verification>
<success_criteria>
- CONFIG-01 需求满足:LLM 分段功能可通过配置启用/禁用
- KBSettings 配置类符合 pydantic-settings 规范
- 测试覆盖默认值、环境变量覆盖、布尔解析
</success_criteria>
<output>
After completion, create `.planning/phases/15-output-compat/15-01-SUMMARY.md`
</output>
@@ -0,0 +1,243 @@
---
phase: 15-output-compat
plan: 02
type: execute
wave: 1
depends_on: [15-01]
files_modified:
- kb_workflow/pipeline/processors/srt.py
- tests/test_processors/test_srt.py
autonomous: true
requirements:
- CONFIG-01
- CONFIG-02
- OUTPUT-01
- OUTPUT-02
- OUTPUT-03
must_haves:
truths:
- "SRTProcessor 从 KBSettings 读取 enable_semantic_segmentation 配置"
- "构造函数参数可覆盖配置值(优先级:参数 > 配置)"
- "配置禁用时使用规则分段器(SemanticSegmenter)"
- "配置启用时使用 LLM 语义分段器(SemanticSegmentationEngine)"
- "输出格式与配置匹配:LLM 分段输出 H2 标题,规则分段输出 '## 内容'"
artifacts:
- path: "kb_workflow/pipeline/processors/srt.py"
provides: "SRTProcessor 配置集成"
exports: ["SRTProcessor.__init__()", "SRTProcessor.process()"]
- path: "tests/test_processors/test_srt.py"
provides: "配置集成测试"
contains: "TestConfigIntegration"
key_links:
- from: "SRTProcessor.__init__()"
to: "get_settings()"
via: "from kb_workflow.pipeline.config import get_settings"
pattern: "get_settings\\(\\)"
- from: "SRTProcessor.__init__()"
to: "KBSettings.enable_semantic_segmentation"
via: "settings.enable_semantic_segmentation"
pattern: "settings\\.enable_semantic_segmentation"
- from: "SRTProcessor.process()"
to: "SemanticSegmenter or SemanticSegmentationEngine"
via: "self.segmenter.segment()"
pattern: "self\\.segmenter\\.segment\\(\\)"
---
<objective>
修改 SRTProcessor 以从 KBSettings 读取 enable_semantic_segmentation 配置,实现配置驱动的分段策略选择,并验证输出格式兼容性。
Purpose: 用户通过配置文件控制 LLM 分段,无需修改调用代码
Output: SRTProcessor 集成 KBSettings,配置优先级正确,输出格式符合预期
</objective>
<execution_context>
@/home/starmen1265/.claude/get-shit-done/workflows/execute-plan.md
@/home/starmen1265/.claude/get-shit-done/templates/summary.md
</execution_context>
<context>
@.planning/phases/15-output-compat/15-CONTEXT.md
@.planning/phases/15-output-compat/15-RESEARCH.md
@.planning/phases/14-robustness-cost/14-05-SUMMARY.md
@.planning/phases/15-output-compat/15-01-SUMMARY.md
@kb_workflow/pipeline/processors/srt.py
@kb_workflow/srt/semantic_engine.py
</context>
<interfaces>
<!-- SRTProcessor 现有构造函数 -->
From kb_workflow/pipeline/processors/srt.py (lines 48-66):
```python
def __init__(
self,
state_manager: Optional[WorkflowStateManager] = None,
enable_correction: bool = True,
enable_semantic_segmentation: bool = False, # 当前硬编码默认值 False
enable_cache: bool = True
):
super().__init__(state_manager)
self.enable_correction = enable_correction
self.enable_semantic_segmentation = enable_semantic_segmentation
# ... 初始化分段器
```
<!-- Pattern: 从 KBSettings 读取配置 -->
```python
# 如果未明确指定,从配置读取
if enable_semantic_segmentation is None:
settings = get_settings()
enable_semantic_segmentation = settings.enable_semantic_segmentation
```
<!-- _generate_markdown 现有逻辑(lines 302-324) -->
From kb_workflow/pipeline/processors/srt.py:
```python
# 检查是否是 VideoSegment 类型(LLM 分段结果)
is_semantic_segmentation = (
paragraphs and
hasattr(paragraphs[0], 'title') and
hasattr(paragraphs[0], 'content')
)
if is_semantic_segmentation:
# LLM 语义分段:包含标题和内容
for seg in paragraphs:
if seg.title:
content_parts.append(f"## {seg.title}")
content_parts.append("")
content_parts.append(seg.content)
content_parts.append("")
else:
# 规则分段:纯文本
content_parts.append("## 内容")
content_parts.append("")
for para in paragraphs:
content_parts.append(para)
content_parts.append("")
```
</interfaces>
<tasks>
<task type="auto" tdd="true">
<name>Task 1: 修改 SRTProcessor 从 KBSettings 读取配置</name>
<files>kb_workflow/pipeline/processors/srt.py, tests/test_processors/test_srt.py</files>
<behavior>
- Test 1: enable_semantic_segmentation=None 时从 KBSettings 读取配置
- Test 2: 显式传入参数时覆盖配置值(参数优先级高于配置)
- Test 3: 配置为 True 且无参数时使用 LLM 分段
- Test 4: 配置为 False 且无参数时使用规则分段
- Test 5: 初始化日志记录配置状态(INFO 级别)
</behavior>
<action>
1. 修改 SRTProcessor.__init__() 签名,将 enable_semantic_segmentation 默认值改为 None:
```python
def __init__(
self,
state_manager: Optional[WorkflowStateManager] = None,
enable_correction: bool = True,
enable_semantic_segmentation: Optional[bool] = None, # 改为 None
enable_cache: bool = True
):
```
2. 在初始化代码中添加配置读取逻辑(在 super().__init__() 之后):
```python
# 如果未明确指定,从配置读取
if enable_semantic_segmentation is None:
settings = get_settings()
enable_semantic_segmentation = settings.enable_semantic_segmentation
logger.info(
f"SRTProcessor using config: "
f"semantic_segmentation={'enabled' if enable_semantic_segmentation else 'disabled'}"
)
elif enable_semantic_segmentation:
logger.info("SRTProcessor using explicit parameter: semantic_segmentation=enabled")
else:
logger.info("SRTProcessor using explicit parameter: semantic_segmentation=disabled")
self.enable_correction = enable_correction
self.enable_semantic_segmentation = enable_semantic_segmentation
```
3. 实现测试(移除 skip 标记):
- test_srt_processor_reads_from_kbsettings
- test_srt_processor_constructor_overrides_config
- test_config_disabled_uses_rule_based
- test_config_enabled_uses_llm_segmentation
测试需要 mock get_settings() 和环境变量。
</action>
<verify>
<automated>pytest tests/test_processors/test_srt.py::TestConfigIntegration -x -v</automated>
</verify>
<done>
- SRTProcessor 从 KBSettings 读取配置
- 构造函数参数可覆盖配置
- 日志记录配置状态
- 4 个测试全部通过
</done>
</task>
<task type="auto" tdd="true">
<name>Task 2: 验证输出格式兼容性</name>
<files>tests/test_processors/test_srt.py</files>
<behavior>
- Test 1: LLM 分段输出带 H2 标题的 Markdown(OUTPUT-01)
- Test 2: title=None 时不输出标题(OUTPUT-02)
- Test 3: 规则分段输出 "## 内容" 标题(OUTPUT-03)
- Test 4: 两种模式输出结构不同但都有效
</behavior>
<action>
实现 _generate_markdown 输出格式验证测试(移除 skip 标记):
1. test_output_format_with_semantic_enabled:
- Mock SemanticSegmentationEngine 返回 VideoSegment 对象
- 验证生成 Markdown 包含 "## {title}" 格式
- 验证有 title 的分段输出标题
2. test_output_format_with_semantic_disabled:
- 使用规则分段器(SemanticSegmenter)
- 验证生成 Markdown 包含 "## 内容" 标题
- 验证段落直接输出,无分段标题
3. test_output_format_with_null_title:
- Mock 返回 title=None 的 VideoSegment
- 验证不输出标题,直接输出内容
这些是集成测试,需要创建完整的 SRTProcessor 并调用 _generate_markdown。
</action>
<verify>
<automated>pytest tests/test_processors/test_srt.py::TestConfigIntegration::test_output_format_with_semantic_enabled tests/test_processors/test_srt.py::TestConfigIntegration::test_output_format_with_semantic_disabled tests/test_processors/test_srt.py::TestConfigIntegration::test_output_format_with_null_title -x -v</automated>
</verify>
<done>
- 输出格式测试通过
- LLM 分段输出 H2 标题(OUTPUT-01 满足)
- title=None 时不输出标题(OUTPUT-02 满足)
- 规则分段输出 "## 内容"(OUTPUT-03 满足)
</done>
</task>
</tasks>
<verification>
- SRTProcessor 正确读取 KBSettings 配置
- 构造函数参数优先级正确(参数 > 配置)
- 配置禁用时使用规则分段器(CONFIG-02 满足)
- 输出格式符合预期(OUTPUT-01, OUTPUT-02, OUTPUT-03 满足)
- 日志记录配置状态便于调试
- 不影响现有测试
</verification>
<success_criteria>
- CONFIG-01 需求满足:SRTProcessor 从 KBSettings 读取配置
- CONFIG-02 需求满足:禁用时使用规则分段
- OUTPUT-01, OUTPUT-02, OUTPUT-03 需求满足:输出格式正确
- 向后兼容:现有代码不传参数时使用配置默认值(True)
</success_criteria>
<output>
After completion, create `.planning/phases/15-output-compat/15-02-SUMMARY.md`
</output>
@@ -0,0 +1,222 @@
---
phase: 15-output-compat
plan: 03
type: execute
wave: 1
depends_on: [15-01, 15-02]
files_modified:
- tests/test_backward_compat.py
- tests/test_processors/test_analyze.py
autonomous: true
requirements:
- CONFIG-02
- CONFIG-03
must_haves:
truths:
- "规则分段行为与 Phase 12 完全一致,未受配置变更影响"
- "AnalyzeProcessor(知乎/文章)继续正常工作,不受 SRTProcessor 配置影响"
- "现有 API 调用保持兼容,不传参数时使用配置默认值"
- "禁用 LLM 分段时性能与 Phase 12 一致(无额外开销)"
artifacts:
- path: "tests/test_backward_compat.py"
provides: "向后兼容性测试"
contains: "TestBackwardCompatibility"
- path: "tests/test_processors/test_analyze.py"
provides: "AnalyzeProcessor 独立性验证"
contains: "现有测试"
key_links:
- from: "AnalyzeProcessor"
to: "SRTProcessor"
via: "独立的处理器类,无依赖"
pattern: "class AnalyzeProcessor"
- from: "规则分段器(SemanticSegmenter)"
to: "SRTProcessor"
via: "enable_semantic_segmentation=False"
pattern: "SemanticSegmenter\\(\\)"
---
<objective>
验证向后兼容性,确保配置变更不影响现有功能,特别是规则分段和 AnalyzeProcessor。
Purpose: 确保用户升级后无需修改代码,现有功能继续正常工作
Output: 向后兼容性测试通过,无破坏性变更
</objective>
<execution_context>
@/home/starmen1265/.claude/get-shit-done/workflows/execute-plan.md
@/home/starmen1265/.claude/get-shit-done/templates/summary.md
</execution_context>
<context>
@.planning/phases/15-output-compat/15-CONTEXT.md
@.planning/phases/12-srt-processor/12-01-SUMMARY.md
@.planning/phases/15-output-compat/15-01-SUMMARY.md
@.planning/phases/15-output-compat/15-02-SUMMARY.md
@kb_workflow/pipeline/processors/srt.py
@kb_workflow/pipeline/processors/analyze.py
@kb_workflow/srt/segmenter.py
</context>
<interfaces>
<!-- AnalyzeProcessor 独立性 -->
From kb_workflow/pipeline/processors/analyze.py (expected structure):
```python
class AnalyzeProcessor(BaseProcessor):
"""知乎/文章处理器,独立于 SRTProcessor"""
# AnalyzeProcessor 不依赖 SRTProcessor 的配置或分段逻辑
# 它有自己的分析流程和输出格式
```
<!-- 规则分段器(SemanticSegmenter) -->
From kb_workflow/srt/segmenter.py (expected structure):
```python
class SemanticSegmenter:
"""规则分段器,基于时间间隔和字符长度"""
def segment(self, segments: List[Segment]) -> List[str]:
# 简单规则:时间间隔 > 3秒 或 字符数 > 500 创建新分段
# 返回纯文本列表,不包含标题
```
<!-- 现有 API 调用模式 -->
```python
# Phase 12 的调用方式(应继续工作)
processor = SRTProcessor(state_manager)
# 或
processor = SRTProcessor(state_manager, enable_correction=False)
# 现在会从 KBSettings 读取 enable_semantic_segmentation(默认 True)
```
</interfaces>
<tasks>
<task type="auto" tdd="true">
<name>Task 1: 验证规则分段向后兼容性</name>
<files>tests/test_backward_compat.py</files>
<behavior>
- Test 1: enable_semantic_segmentation=False 时使用规则分段器
- Test 2: 规则分段输出格式与 Phase 12 一致("## 内容"标题)
- Test 3: 规则分段不调用 LLM,无网络开销
- Test 4: 规则分段的分段逻辑(时间/长度阈值)未改变
</behavior>
<action>
实现规则分段兼容性测试(移除 skip 标记):
1. test_rule_based_segmentation_unchanged:
- 创建 SRTProcessor(enable_semantic_segmentation=False)
- 验证 self.segmenter 是 SemanticSegmenter 实例
- 验证不是 SemanticSegmentationEngine 实例
- 调用 segment() 方法验证返回纯文本列表
- 验证输出 Markdown 包含 "## 内容" 标题
2. test_rule_based_no_llm_calls:
- Mock SimpleAIClient,验证 generate() 方法未被调用
- 确保规则分段不依赖 LLM
3. test_rule_based_thresholds_unchanged:
- 使用已知字幕数据测试分段边界
- 验证分段逻辑与 Phase 12 一致(时间间隔 3秒,字符数 500)
测试数据使用 Phase 12 的测试模式。
</action>
<verify>
<automated>pytest tests/test_backward_compat.py::TestBackwardCompatibility::test_rule_based_segmentation_unchanged tests/test_backward_compat.py::TestBackwardCompatibility::test_rule_based_no_llm_calls tests/test_backward_compat.py::TestBackwardCompatibility::test_rule_based_thresholds_unchanged -x -v</automated>
</verify>
<done>
- 规则分段测试通过
- 行为与 Phase 12 一致
- CONFIG-02 需求满足
</done>
</task>
<task type="auto" tdd="true">
<name>Task 2: 验证 AnalyzeProcessor 独立性</name>
<files>tests/test_processors/test_analyze.py, tests/test_backward_compat.py</files>
<behavior>
- Test 1: AnalyzeProcessor 不受 KBSettings.enable_semantic_segmentation 影响
- Test 2: AnalyzeProcessor 正常初始化和处理
- Test 3: AnalyzeProcessor 输出格式未改变
</behavior>
<action>
实现 AnalyzeProcessor 独立性测试:
1. 在 test_backward_compat.py 中添加 test_analyze_processor_unaffected:
- 设置 KB_ENABLE_SEMANTIC_SEGMENTATION=true 或 false
- 创建 AnalyzeProcessor
- 验证处理器正常工作
- 验证 AnalyzeProcessor 不读取 enable_semantic_segmentation 配置
2. 验证 tests/test_processors/test_analyze.py 中现有测试全部通过:
- 确保 AnalyzeProcessor 的测试未被配置变更破坏
- AnalyzeProcessor 有独立的测试套件
AnalyzeProcessor 处理知乎/文章内容,与视频字幕处理完全独立。
</action>
<verify>
<automated>pytest tests/test_backward_compat.py::TestBackwardCompatibility::test_analyze_processor_unaffected tests/test_processors/test_analyze.py -x -v</automated>
</verify>
<done>
- AnalyzeProcessor 测试通过
- CONFIG-03 需求满足
- 现有测试未受影响
</done>
</task>
<task type="auto" tdd="true">
<name>Task 3: 验证 API 调用兼容性</name>
<files>tests/test_backward_compat.py</files>
<behavior>
- Test 1: 不传 enable_semantic_segmentation 参数时使用配置默认值
- Test 2: 旧代码调用 SRTProcessor(state_manager) 继续工作
- Test 3: 显式传 False 时覆盖配置,使用规则分段
</behavior>
<action>
实现 API 兼容性测试:
1. test_existing_api_compatibility:
- 模拟 Phase 12 的调用方式:SRTProcessor(state_manager)
- 验证从 KBSettings 读取配置(默认 True)
- Mock get_settings() 返回 enable_semantic_segmentation=True
2. test_explicit_false_overrides_config:
- 设置配置 KB_ENABLE_SEMANTIC_SEGMENTATION=true
- 调用 SRTProcessor(state_manager, enable_semantic_segmentation=False)
- 验证使用规则分段器(参数优先)
3. test_migration_path:
- 验证用户可以通过两种方式启用语义分段:
a) 不传参数,配置文件设置 KB_ENABLE_SEMANTIC_SEGMENTATION=true
b) 代码中显式传入 enable_semantic_segmentation=True
确保升级路径平滑,用户无需立即修改代码。
</action>
<verify>
<automated>pytest tests/test_backward_compat.py::TestBackwardCompatibility::test_existing_api_compatibility tests/test_backward_compat.py::TestBackwardCompatibility::test_explicit_false_overrides_config tests/test_backward_compat.py::TestBackwardCompatibility::test_migration_path -x -v</automated>
</verify>
<done>
- API 兼容性测试通过
- 升级路径清晰
- 无破坏性变更
</done>
</task>
</tasks>
<verification>
- 规则分段行为与 Phase 12 一致(CONFIG-02 满足)
- AnalyzeProcessor 不受影响(CONFIG-03 满足)
- 现有 API 调用保持兼容
- 配置默认值为 True,提供开箱即用的语义分段体验
- 用户可选择禁用(配置或参数)
- 所有现有测试通过
</verification>
<success_criteria>
- CONFIG-02 需求满足:向后兼容,不破坏现有规则分段
- CONFIG-03 需求满足:AnalyzeProcessor 不受影响
- 无破坏性变更,用户可平滑升级
- 测试覆盖所有兼容性场景
</success_criteria>
<output>
After completion, create `.planning/phases/15-output-compat/15-03-SUMMARY.md`
</output>