Skip to main content

Module rewind

Module rewind 

Source
Expand description

Selective rewind for a session’s checkpoint chain.

Reads checkpoints.jsonl, identifies which files this session touched in turns >= the rewind cutoff, detects conflicts where the current workspace state diverges from this session’s last known post-snapshot for those files, and asks ShadowRepo::restore_paths to revert only that file subset.

Multi-session safety: because restore_paths operates on a path whitelist, files modified by a sibling session are never touched unless they happen to also fall within this session’s touched set (in which case the conflict is surfaced and the user must --force).

Structs§

ConflictReport
Outcome of a [rewind] call when conflicts were detected.
RewindPlan
Plan describing what a rewind would do, for a dry-run preview.
RewindResult
Result of a successful rewind.

Functions§

apply_rewind
Apply a rewind plan: restore files, then truncate the checkpoint log. Transcript truncation is left to the caller because it owns transcript.jsonl.
checkpoint_log_path
Convenience: locate checkpoints.jsonl for a session given the workspace root and a session id. Mirrors the path layout chosen by SessionWriter.
detect_conflicts
Check whether the workspace’s current state for the touched files matches the session’s last-known post-snapshot. Returns the list of conflicting paths (empty list = safe to proceed).
plan_rewind
Compute a RewindPlan for rewinding to_turn.