pub fn freshen_session(
claude_home: &Path,
project: &str,
agent: &str,
) -> Result<Option<PathBuf>>Expand description
T-352: move aside the on-disk Claude session JSONL for (project, agent)
so the wrapper’s resume-probe misses on the next spawn and Claude opens a
brand-new conversation at the same deterministic UUID (re-running
BOOTSTRAP_PROMPT). The --fresh escape hatch from always-on resume
(T-118); durable on-disk files are never touched — only the session JSONL.
claude_home is ~/.claude (injected so tests don’t touch the real home).
Globs projects/*/<uuid>.jsonl exactly like the wrapper, because Claude’s
cwd→project-dir slug is observed-not-documented; the UUIDv5 is globally
unique so at most one file ever matches.
The move is a single rename(2) to <uuid>.jsonl.bak within the same
directory — atomic, with no half-moved state. The prior conversation is
preserved (not deleted) as a one-slot recovery; a subsequent --fresh
replaces it. A crash after the rename but before respawn is fail-safe: the
next boot finds no JSONL and comes up fresh anyway, which is exactly the
requested intent. A non---fresh boot never moves anything, so a session
the operator wanted to keep can never be lost by this path.
Returns the .bak path on a successful move, or None when there was no
session on disk (agent never ran, or already fresh).