Skip to content

Prevent stale Clone Loop auto-resume#15

Merged
Turtle-Hwan merged 6 commits into
mainfrom
feat/fix-ghost-loop-stale-state
May 22, 2026
Merged

Prevent stale Clone Loop auto-resume#15
Turtle-Hwan merged 6 commits into
mainfrom
feat/fix-ghost-loop-stale-state

Conversation

@Turtle-Hwan
Copy link
Copy Markdown
Contributor

@Turtle-Hwan Turtle-Hwan commented May 22, 2026

Summary

Fixes CLO-46.

Fixes the Clone Loop ghost-loop safety bug reported in Slack and tracked as CLO-46: stale .claude/clone-loop.local.md can no longer auto-resume in a new Claude Code session.

Slack report: https://cloneisyou.slack.com/archives/C0AQUR7PBFW/p1779431888914289
Linear issue: https://linear.app/cloneisyou/issue/CLO-46/ghost-loop-auto-resumes-from-stale-local-state

Root cause

The Stop hook treated the presence of .claude/clone-loop.local.md as sufficient proof that a loop was active. On session_id mismatch it patched the state file to the new session and continued, which let a stale local state file inject fabricated user prompts into an unrelated new session.

Changes

  • Add a shared active-loop guard for Stop, AskUserQuestion, and PostToolUse hooks.
  • Require the current hook session_id to match the state session_id.
  • Require a current-session loop-start event in .claude/clone-loop.history.local.jsonl.
  • Expire local loop state after 24 hours of loop inactivity.
  • Remove stale/corrupt/expired loop state instead of continuing silently.
  • Replace the old session-rotation test with regression coverage that ensures no MCP calls and no prompt injection happen for stale state.

Validation

  • Targeted regression tests: node --test tests/post-tool-use-capture.test.mjs tests/stop-hook-v2.test.mjs tests/ask-user-question-hook.test.mjs -> 27/27 pass
  • Release workflow for the merged PR passed and published clone--v0.14.1/later patch releases.

Acceptance mapping for CLO-46

  • Stale .claude/clone-loop.local.md in a brand-new session: blocked by strict session_id match.
  • Missing current-session loop-start: blocked and stale state removed.
  • Stop hook auto-continue on session mismatch: removed; now no MCP call and no injected prompt.
  • AskUserQuestion auto-answer from stale state: blocked by the same active-loop guard.
  • PostToolUse stale context capture: blocked by the same active-loop guard.

@Turtle-Hwan Turtle-Hwan changed the title [codex] Prevent stale Clone Loop auto-resume Prevent stale Clone Loop auto-resume May 22, 2026
@Turtle-Hwan Turtle-Hwan marked this pull request as ready for review May 22, 2026 07:42
@Turtle-Hwan Turtle-Hwan merged commit d6ca61e into main May 22, 2026
@Turtle-Hwan Turtle-Hwan deleted the feat/fix-ghost-loop-stale-state branch May 22, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant