summaryrefslogtreecommitdiff
path: root/plugins/ralph-loop/scripts
diff options
context:
space:
mode:
authorsfishman <sfishman@anthropic.com>2026-03-02 22:36:12 +0000
committersfishman <sfishman@anthropic.com>2026-03-02 22:52:00 +0000
commit8644df9ad51fe1dadc5d067e806c3c686efeafff (patch)
tree199e5d167a22527832277c9b8a423f4b71afa487 /plugins/ralph-loop/scripts
parentadfc3796639cd0c5d892fb05303b4b2cddfe6e12 (diff)
fix(ralph-loop): isolate loop state to the session that started it
The state file lives at .claude/ralph-loop.local.md — project-scoped, not session-scoped. The plugin's Stop hook fires in every Claude Code session open in that project directory. So if session A starts a loop, session B's Stop events also find the state file and block, feeding A's prompt into B and consuming A's iteration budget. This was masked by the transcript-parsing bug fixed in the previous commit: that bug deleted the state file on the first Stop in any session, so neither session looped. Fixing it exposed the leak. Fix: setup writes CLAUDE_CODE_SESSION_ID into the frontmatter; the hook compares against .session_id from its stdin JSON and exits silently on mismatch. State files without session_id (written by old setup scripts) fall through to preserve existing behavior.
Diffstat (limited to 'plugins/ralph-loop/scripts')
-rwxr-xr-xplugins/ralph-loop/scripts/setup-ralph-loop.sh1
1 files changed, 1 insertions, 0 deletions
diff --git a/plugins/ralph-loop/scripts/setup-ralph-loop.sh b/plugins/ralph-loop/scripts/setup-ralph-loop.sh
index 3d41db4a..c0897d45 100755
--- a/plugins/ralph-loop/scripts/setup-ralph-loop.sh
+++ b/plugins/ralph-loop/scripts/setup-ralph-loop.sh
@@ -141,6 +141,7 @@ cat > .claude/ralph-loop.local.md <<EOF
---
active: true
iteration: 1
+session_id: ${CLAUDE_CODE_SESSION_ID:-}
max_iterations: $MAX_ITERATIONS
completion_promise: $COMPLETION_PROMISE_YAML
started_at: "$(date -u +%Y-%m-%dT%H:%M:%SZ)"