Skip to content

refactor(run): extract session, quality gate, and exit detection libraries #132

@LarsCowe

Description

@LarsCowe

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):

  1. ralph/lib/session_manager.sh — all session lifecycle functions (init_session_tracking, update_session_last_used, reset_session, log_session_transition, etc.)
  2. ralph/lib/quality_gates.shrun_test_gate, run_custom_gates, run_quality_gates, validation functions
  3. ralph/lib/exit_detection.shshould_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

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-qualityCode quality improvementsralph-loopRalph autonomous loop improvements

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions