15 Commits

Author SHA1 Message Date
starmen1265 f2a1847557 test(15-01): add failing test for enable_semantic_segmentation field
- Test KBSettings has enable_semantic_segmentation field with bool type
- Test default value is True
- Test environment variable override (KB_ENABLE_SEMANTIC_SEGMENTATION)
- Test boolean string parsing (true/false, yes/no, 1/0)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 23:01:20 +08:00
starmen1265 c9ca1b538d refactor(06-02): update CLI and test imports to kb_workflow.pipeline
- Remove sys.path manipulation from kb_workflow.py
- Update CLI imports to use kb_workflow.pipeline prefix
- Update all test file imports and patch paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:17:10 +08:00
starmen1265 360aee200f test(05-03): add Pipeline archive integration tests
- Test pipeline includes archive step
- Test archive uses platform directory structure
- Test no date-based subdirectories in archive
- Update default steps assertion to include archive

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 23:26:14 +08:00
starmen1265 5d4cb93f8b test(04-04): add schema validation tests for PipelineInput/Output/Config
- Test PipelineInput validates url field (required)
- Test PipelineOutput contains results dict
- Test PipelineConfig has default steps list
- Test PipelineConfig allows custom output_dir

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 23:37:28 +08:00
starmen1265 efddef98d3 feat(04-01): add ParseInput and ParseOutput schemas
- ParseInput extends StepInput with url field
- ParseOutput extends StepOutput with platform, content_type, content_id, resolved_url, original_url
- Tests for schema validation and inheritance

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 23:11:44 +08:00
starmen1265 bd29425d28 feat(02-01): add IdempotencyChecker for file existence checking
- Create IdempotencyChecker class with check_exists method
- Check for metadata JSON and content Markdown files
- Return tuple of (all_exist, existing_files)
- Follow naming convention: {platform}_{content_id}_{type}.{ext}
- Add get_expected_files helper method
- Add 8 unit tests covering all scenarios

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 18:13:35 +08:00
starmen1265 dd94f068e7 feat(02-01): add LinkParser and ParsedLink for unified URL parsing
- Create ParsedLink dataclass with platform, content_type, content_id fields
- Implement LinkParser class with regex-based URL parsing
- Support Bilibili video/article URLs (with/without www)
- Support Zhihu answer/zhuanlan URLs
- Support b23.tv short link resolution with requests.head
- Return None for unrecognized URLs (no exceptions)
- Add 15 unit tests covering all supported URL types

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 18:12:16 +08:00
starmen1265 c87dd8b803 test(01-03): add failing tests for retry mechanism
- Test retry on NetworkError (up to 3 times)
- Test no retry on non-NetworkError (ValidationError)
- Test reraise after max attempts
- Test preserved return value on success
- Test exponential backoff configuration
- Test cause exception preservation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 17:17:51 +08:00
starmen1265 44b5d18113 feat(01-03): implement configuration management with pydantic-settings
- KBSettings class loading from ~/.kb_env file
- Required fields: base_path, archive_path
- Optional fields: git_root, git_user, git_email
- Secret fields: hf_token, zhihu_cookie (SecretStr)
- get_settings() singleton with lru_cache
- env_prefix "KB_" for environment variables
- Tests adjusted for proper env isolation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 17:17:10 +08:00
starmen1265 624cd76538 feat(01-01): implement WorkflowStateManager with atomic write
GREEN phase: Implement state management with:
- Atomic write pattern (temp file + os.replace)
- Backup rotation (workflow_state.json -> .bak)
- Backup fallback on corruption
- get_or_create idempotent creation

Fix test to properly create backup before corruption test.

All 20 tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 17:16:30 +08:00
starmen1265 e789d81230 test(01-03): add failing tests for configuration management
- Test KBSettings required fields (base_path, archive_path)
- Test KBSettings optional fields with defaults
- Test secret fields (hf_token, zhihu_cookie) as SecretStr
- Test missing required fields raises ValidationError
- Test get_settings returns singleton via lru_cache
- Test env vars with KB_ prefix are read

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 17:15:35 +08:00
starmen1265 246e4038b4 test(01-01): add failing tests for WorkflowStateManager
RED phase: 20 test cases for:
- WorkflowState.is_step_completed (5 tests)
- WorkflowState.mark_step_* methods (4 tests)
- WorkflowStateManager atomic write (4 tests)
- WorkflowStateManager backup fallback (4 tests)
- WorkflowStateManager.get_or_create (3 tests)

11 tests fail due to missing kb_pipeline.state module.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 17:15:02 +08:00
starmen1265 840559075a test(01-03): add failing tests for error handling
- Test ErrorType enum (NETWORK, VALIDATION, SYSTEM, AUTH)
- Test KBError base class with to_dict method
- Test NetworkError with status_code and auto-suggestion
- Test ValidationError with validation_errors list
- Test SystemError with system_message
- Test AuthError with auth_type
- Test error class hierarchy

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 17:13:50 +08:00
starmen1265 7ffaafd615 refactor(01-02): add comprehensive tests for full coverage
- Add tests for WorkflowState methods (mark_step_started, mark_step_completed, mark_step_failed)
- Add tests for StepResult schema
- Add tests for StepDefinition schema with dependencies
- Achieve 100% test coverage on kb_pipeline/schemas.py
- Total 37 tests passing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 17:08:51 +08:00
starmen1265 85413bc1c6 test(01-02): add failing tests for core pipeline schemas
- Create kb_pipeline package structure
- Add test fixtures in conftest.py
- Add 28 test cases for StepInput, StepOutput, StepStatus, StepRecord, WorkflowState
- Add JSON serialization/deserialization tests
- TDD RED phase: tests fail because schemas.py not yet implemented

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 17:05:37 +08:00