refactor: extract core/workflow/ subdirectory#121
Conversation
Move 6 workflow-related files from core/ into core/workflow/: - workflow_manager.py → workflow/manager.py - workflow_validator.py → workflow/validator.py - workflow_save_service.py → workflow/save_service.py - workflow_data_flow.py → workflow/data_flow.py - workflow_status.py → workflow/status.py - skill_service.py → workflow/skill_service.py Create workflow/__init__.py with re-exports and workflow/CLAUDE.md. Update all imports (36 src files, 30 test files), 52 mock.patch strings, and 8 CLAUDE.md files. Remove dead re-exports from core/__init__.py. Also: improve refactor command with lessons learned (sed over subagents for bulk replacements, relative import auditing, intermediate checkpoints, __init__.py transitive loading warning, CLAUDE.md content placement). Also: add Design Decisions section to template_validation/CLAUDE.md. 4128 passed, 485 skipped — zero regressions.
Context: Why this refactor is neededThis PR is the pre-task for a larger effort: removing the gated The bigger pictureThe planning module (~7,300 production lines, ~23,000 test lines) and repair system (~1,050 production lines) were gated by Task 107 (markdown format migration). All code is preserved but unreachable — 516 skipped tests, entry-point guards everywhere. The architecture docs call the planner "legacy" and "being phased out." Rather than maintaining this dormant code, we're removing it cleanly in 3 phases:
Why extract
|
Summary
Extract 6 workflow-related files from
src/pflow/core/into a newsrc/pflow/core/workflow/subdirectory. Preparatory refactor for the planning module removal (Phase 1 places new files intocore/workflow/).Changes
File moves (via
git mv, history preserved):workflow_manager.py→workflow/manager.pyworkflow_validator.py→workflow/validator.pyworkflow_save_service.py→workflow/save_service.pyworkflow_data_flow.py→workflow/data_flow.pyworkflow_status.py→workflow/status.pyskill_service.py→workflow/skill_service.pyNew files:
core/workflow/__init__.py— re-exports all public symbols (22 symbols from 6 modules)core/workflow/CLAUDE.md— per-file details, internal dependencies, known issues, key lessonsImport updates:
mock.patch()string targets updatedCleanup:
core/__init__.py(zero consumers forWorkflowValidator,CycleError,build_execution_order,validate_data_flowvia that path)core/CLAUDE.md— workflow-specific content moved toworkflow/CLAUDE.md, parent keeps cross-cutting concernsAlso included:
template_validation/CLAUDE.md— added Design Decisions section (two regex patterns, coalesce pre-splitting, type matrix, validation boundaries).claude/commands/refactor.md— lessons learned: sed for bulk replacements, relative import auditing, intermediate checkpoints,__init__.pytransitive loading, CLAUDE.md content placementExplanation
core/had 20+ files and was becoming cluttered. The 6 workflow files form a cohesive group (they cross-reference each other, share the same domain). Extracting them into a subdirectory reduces noise for agents working on unrelated core files (settings, metrics, shell integration) and gives the workflow domain its own CLAUDE.md for detailed documentation.This is the pre-task for the planning module removal — Phase 1 of that work places new discovery functions into
core/workflow/, so the subdirectory needs to exist first.Testing
Zero regressions. Stale reference sweep confirms zero old-path references in any
.pyor.mdfile.