Problem
ralph_loop.sh is ~2750 lines. Session management (~400 lines), quality gates (~200 lines), and exit detection logic are all inline, making the file hard to test, debug, and extend.
Proposal
Pure extraction (no behavior change):
ralph/lib/session_manager.sh — all session lifecycle functions (init_session_tracking, update_session_last_used, reset_session, log_session_transition, etc.)
ralph/lib/quality_gates.sh — run_test_gate, run_custom_gates, run_quality_gates, validation functions
ralph/lib/exit_detection.sh — should_exit_gracefully(), count_fix_plan_checkboxes(), enforce_fix_plan_progress_tracking()
Source them in ralph_loop.sh alongside existing library sources.
Files
ralph/ralph_loop.sh — extract ~800 lines
- New:
ralph/lib/session_manager.sh
- New:
ralph/lib/quality_gates.sh
- New:
ralph/lib/exit_detection.sh
Priority
11/16 — High impact on maintainability, 4 hours effort
Problem
ralph_loop.shis ~2750 lines. Session management (~400 lines), quality gates (~200 lines), and exit detection logic are all inline, making the file hard to test, debug, and extend.Proposal
Pure extraction (no behavior change):
ralph/lib/session_manager.sh— all session lifecycle functions (init_session_tracking,update_session_last_used,reset_session,log_session_transition, etc.)ralph/lib/quality_gates.sh—run_test_gate,run_custom_gates,run_quality_gates, validation functionsralph/lib/exit_detection.sh—should_exit_gracefully(),count_fix_plan_checkboxes(),enforce_fix_plan_progress_tracking()Source them in
ralph_loop.shalongside existing library sources.Files
ralph/ralph_loop.sh— extract ~800 linesralph/lib/session_manager.shralph/lib/quality_gates.shralph/lib/exit_detection.shPriority
11/16 — High impact on maintainability, 4 hours effort