Skip to content

[S4] Add session persistence and crash recovery to LoopOrchestrator #92

@federiconeri

Description

@federiconeri

Summary

Add full session state serialization and crash recovery to the LoopOrchestrator runtime (#69), replacing the current fragile /tmp file-based status tracking.

Problem / Context

Currently, loop state is tracked via multiple /tmp/ralph-loop-<feature>.* files (status, tokens, phases, baseline, log). If Wiggum crashes or the terminal closes, recovery is limited to what the --resume flag can reconstruct from these temp files.

Competitors have full session persistence with resume that restores complete state, session locking to prevent concurrent runs, and cross-project session registries. As we build the LoopOrchestrator (#69), session persistence should be a first-class concern — not bolted on after.

Roadmap phase: Phase 2 — CONTROL ("Wiggum owns the full process lifecycle")

Proposed Solution

  • Persist full orchestrator state to .ralph/sessions/<feature>.json (not /tmp)
  • Include: current phase, iteration count, task progress, token usage, git baseline, timestamps, agent config
  • Implement session locking (prevent two loops on same feature)
  • wiggum resume <feature> restores full state and resumes from exact point of interruption
  • Clean up /tmp files on graceful exit; session file persists for crash recovery
  • Consider a session registry in ~/.wiggum/sessions.json for cross-project tracking

Files to Modify

File Changes
src/session/ (new) Session manager, serialization, locking
src/commands/run.ts Integrate session lifecycle with loop execution
src/tui/screens/RunScreen.tsx Display session recovery state

Acceptance Criteria

  • Loop state persisted to .ralph/sessions/ on every phase transition and iteration boundary
  • wiggum resume <feature> restores full state and continues loop
  • Session locking prevents concurrent runs on the same feature
  • Graceful exit cleans up temp files; session file retained for recovery
  • Session survives terminal close, Wiggum crash, and machine reboot

Metadata

Metadata

Assignees

Labels

cliCommand line interface, commands, entry pointsenhancementEnhancement to existing featureinfrastructureDevOps, build, debug tooling

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions