Commit Graph

4 Commits

Author SHA1 Message Date
starmen1265 5c32cfdf69 test(14-01): 实现 LLM 调用的可恢复错误检测和重试逻辑
- 添加 _is_recoverable_error() 静态方法判断错误类型
- 可恢复错误: ConnectionError, Timeout, HTTPError (429/500/502/503/504)
- 不可恢复错误: 其他 HTTPError (4xx), ValidationError
- 重试逻辑: 仅对可恢复错误重试 1 次,立即重试(无延迟)
- 改进日志记录: 重试用 info 级别,降级用 warning 级别
- 降级时记录具体错误类型和消息

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 22:38:28 +08:00
starmen1265 92c300bb21 test(14-00): add test infrastructure for robustness and cost control
- Add comprehensive test suite in test_semantic_robustness.py
  - TestLLMFailureFallback: LLM调用失败自动降级 (ROBUST-01)
  - TestNonRecoverableErrorDetection: 不可恢复错误检测
  - TestRecoverableErrorDetection: 可恢复错误检测
  - TestRetryMechanism: 重试机制测试
  - TestFallbackToRuleBased: 降级到规则分段 (ROBUST-03)
  - TestLoggingBehavior: 日志记录行为 (ROBUST-04)
  - TestParseFailureRetry: 解析失败重试 (ROBUST-02)
  - TestExtractJSON: JSON提取功能

- Update conftest.py with Phase 14 fixtures:
  - Mock AI clients for different failure scenarios
  - Long text samples for chunking tests (COST-01)
  - Cache-related fixtures (COST-02)
  - Long subtitle segments for testing

- Add TestSemanticSegmentationToggle to test_srt_processor.py (COST-03):
  - Test enabling/disabling semantic segmentation
  - Test cache enable/disable functionality
  - Test configuration switches

All tests follow TDD RED state - failing tests for future implementation
2026-03-23 22:37:49 +08:00
starmen1265 970c13a93b test(14-02): add failing test for parse error retry and fallback
- Test JSONDecodeError triggers retry 1 time before fallback
- Test ValidationError directly fallbacks without retry
- Test parse error logs LLM output fragment (first 500 chars)
- Test fallback logs error type and message
- Test retry uses INFO level logging

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 22:36:05 +08:00
starmen1265 b6e923c4a4 test(14-03): add failing tests for SemanticCache
- TestComputeContentHash: 测试内容哈希计算(SHA256)
- TestSemanticCache: 测试缓存读写功能
- 测试覆盖:缓存命中/未命中、版本控制、错误处理、多缓存项

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 22:35:38 +08:00