fix: deliver ruleset on mid-session /ponytail switch (#663) - #667
Open
SomSamantray wants to merge 1 commit into
Open
fix: deliver ruleset on mid-session /ponytail switch (#663)#667SomSamantray wants to merge 1 commit into
SomSamantray wants to merge 1 commit into
Conversation
) The mid-session mode-switch write in ponytail-mode-tracker.js only emitted the confirmation string for non-Qoder platforms (native Claude Code, Codex); ruleset injection was gated behind isQoder, so the main thread stayed rule-less until the next SessionStart even though subagents spawned meanwhile already saw it. Fold the ruleset into the same write, mirroring the pattern Qoder already used. Strengthens the existing native-Claude and Codex mid-session-switch tests, which exercised this exact branch but only asserted the flag file / systemMessage, not the delivered ruleset content.
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
Fixes #663.
The mid-session mode-switch write in
ponytail-mode-tracker.jsonly emitted the confirmation string for non-Qoder platforms (native Claude Code, Codex); the actual ruleset injection (getPonytailInstructions(mode)) was gated behindisQoder && !deactivated. So switching mode mid-session (/ponytail full) updated the flag and printedPONYTAIL MODE CHANGED — level: full, but the main thread never got the rules until the nextSessionStart— while subagents spawned in the meantime already saw them (ponytail-subagent.jsreads the flag independently), producing the split state reported in the issue.The fix folds
getPonytailInstructions(mode)into the existing!isQoderconfirmation write, mirroring the pattern already used on the Qoder branch below it (Qoder has noSessionStartto fall back on, so it always folded the ruleset into everyUserPromptSubmit).Root cause
hooks/ponytail-mode-tracker.js:70-76(before fix): mode-switch write for non-Qoder platforms only sent the confirmation string.hooks/ponytail-mode-tracker.js:96-113: ruleset injection was gated behindisQoder, so it never ran for native Claude Code / Codex.{"prompt":"/ponytail full"}into the hook showed the flag file updated tofull, but stdout contained only the confirmation line — no ruleset. TogglingQODER_SESSION_IDon the identical input confirmed the same code path emitsheader + full rulesetwhenisQoderis true, isolating the gate as the exact cause.Testing notes
tests/hooks.test.js, thedefEnv//ponytail ultracase) to assert the ruleset now appears in stdout, not just the flag file — this test already exercised the buggy path but never checked the payload.@ponytail litecase) the same way, closing a gap a 4-persona review (correctness, project-standards, testing, agent-native) surfaced: the fix is gated by the same!isQoderboolean for Codex, but the pre-existing test only assertedsystemMessage, nothookSpecificOutput.additionalContext.node --test tests/*.test.js— 82/82 passing.Known Residuals (accepted, non-blocking)
getPonytailInstructions(mode)produces two adjacent headers (PONYTAIL MODE CHANGED — level: Xfollowed byPONYTAIL MODE ACTIVE — level: X, since the ruleset body always starts with its own header). This mirrors the exact pattern the pre-existing Qoder fold already used, so it's not a regression — flagged as P3/advisory for a possible future cleanup, not fixed here to keep the diff minimal and scoped to Claude Code: mid-session /ponytail <level> sets the flag and confirms, but the main thread never receives the ruleset #663.writeHookOutputonly emitsadditionalContextonSessionStart), but that's pre-existing, out of scope for Claude Code: mid-session /ponytail <level> sets the flag and confirms, but the main thread never receives the ruleset #663, and unaffected by this diff.Post-Deploy Monitoring & Validation
No runtime/production monitoring applies — this is a local Node hook script with full unit-test coverage (
node --test tests/*.test.js) and no deployed service. Validation is the test suite itself; a regression here would show as a failing assertion intests/hooks.test.js, not a runtime signal.🤖 Generated with Claude Code