Skip to main content

Module session

Module session 

Source
Expand description

Session persistence for crash recovery.

Responsibilities:

  • Save, load, and clear session state to/from .ralph/cache/session.jsonc.
  • Validate session state against current queue state.
  • Provide session recovery detection and prompts.

Not handled here:

  • Session state definition (see crate::contracts::session).
  • Task execution logic (see crate::commands::run).

Invariants/assumptions:

  • Session file is written atomically using fsutil::write_atomic.
  • Session is considered stale if task no longer exists or is not Doing.
  • Session timeout is checked before allowing resume.

Enums§

SessionValidationResult
Result of session validation.

Functions§

check_session
Check for existing session and return validation result.
clear_session
Clear (delete) the session file.
get_git_head_commit
Get the git HEAD commit hash for session tracking.
increment_session_progress
Increment the session’s tasks_completed_in_loop counter and persist.
load_session
Load session state from disk.
prompt_session_recovery
Prompt the user for session recovery confirmation.
prompt_session_recovery_timeout
Prompt the user for session recovery with timeout warning.
save_session
Save session state to disk.
session_exists
Check if a session file exists.
session_path
Get the path to the session file.
validate_session
Validate a session against the current queue state.