fix: scope the machine-global mode flag by project so concurrent sessions stop clobbering each other (#662) - #711
Open
ousamabenyounes wants to merge 1 commit into
Conversation
…ions don't clobber it (DietrichGebert#662) Live mode lives in one machine-global .ponytail-active file, so two Claude Code sessions in different repos step on each other: one writing 'full' leaks the ruleset into a repo configured off, and starting an off session clearMode()s the flag out from under a still-running one. Record which project wrote the flag in a .ponytail-active.owner sidecar keyed by CLAUDE_PROJECT_DIR: - clearMode() refuses to delete a flag owned by another project. - the SubagentStart hook ignores the flag only when this repo defaults off and doesn't own it — ownership whitelists an explicit /ponytail opt-in, it never suppresses a legitimately-active session. Unknown project (non-Claude hosts) falls back to the legacy unscoped behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ousamabenyounes
force-pushed
the
fix/issue-662
branch
from
August 12, 2026 18:15
801aeb8 to
95fcdaf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix #662
Live ponytail mode lives in one machine-global
.ponytail-activefile, so two Claude Code sessions in different repos clobber each other:fullwrites the flag; a concurrent repo B configuredoffthen injects the ruleset into every subagent it spawns, despite beingoff.clearMode(), deleting the flag out from under repo A's still-running session — A's subagents silently stop receiving the ruleset.Fix — attribute the flag to its writer.
setMode()records the writing project in a.ponytail-active.ownersidecar keyed byCLAUDE_PROJECT_DIR(which Claude Code sets per session). Two changes use it:clearMode()refuses to delete a flag owned by a different project — fixes consequence 2.SubagentStarthook ignores the flag only when this repo defaultsoffand doesn't own it — fixes consequence 1.Ownership only whitelists: an explicit
/ponytailopt-in in an otherwise-off repo owns the flag and still injects, so a legitimately-active session is never suppressed. Unknown project (non-Claude hosts, which use their own per-host state dir anyway) falls back to the legacy unscoped behavior, and runtime/ponytailtoggles keep driving subagents unchanged.Test verification (RED → GREEN)
New assertions in
tests/hooks.test.jscover: an off repo ignores a foreign flag, a self-owned opt-in still injects,clearModewon't delete a foreign flag, and a same-repo off session still clears its own.RED — both hooks at unmodified
main, new tests applied:GREEN — full suite with the fix:
node scripts/check-rule-copies.jsandnode scripts/check-versions.jsboth pass.Files changed
hooks/ponytail-runtime.js.ponytail-active.ownersidecar; owner-awareclearMode;ownedByCurrentProjecthooks/ponytail-subagent.jstests/hooks.test.js