Repository navigation
Conversation
…ce test, not after (#448) scripts/resolve-paths.sh tested REMEMBER_HOOK_CWD with `[ -d ]` before the Windows backslash/drive-letter normalization block that would have made a Windows-native-spelled cwd resolvable -- the normalization only ever ran against whatever PROJECT_DIR was already selected. A cwd arriving in Windows-native spelling was therefore tested in the form the shell cannot resolve, discarded, and resolution fell through to the loud failure (silently, via each hook's || exit 0) on a host with no CLAUDE_PROJECT_DIR (Codex, Gemini CLI). The normalization is now a function called on every PROJECT_DIR candidate before it is tested, not once after a candidate is already chosen. CLAUDE_PROJECT_DIR gets the same normalize-then-trust treatment it always implicitly had; REMEMBER_HOOK_CWD keeps its own existence test before selection, now against the normalized form, so a still-unusable value falls through to the next candidate exactly as before. tests/test_windows_native_hook_cwd_448.py covers all four hooks that read this fallback via tests/_bash_runner.py's resolve_bash() so the Windows CI leg exercises it instead of skipping, plus a platform-independent structural pin on the fix's ordering (the actual local red/green: the pin fails against the pre-fix source and passes after) and the existing "must not fire" positive control. Co-Authored-By: Max <noreply>
Self-review (oss:auditor) found that the module-level `pytestmark = pytest.mark.skipif(BASH is None, ...)` silenced test_remember_hook_cwd_is_normalized_before_its_existence_test along with the six bash-dependent hook tests -- but that test is a pure source-text pin with no bash dependency at all, and its own docstring calls it "checkable identically on every platform". A module-level skip for a missing bash therefore misreported what always ran. The skip is now a named marker, `_needs_bash`, applied per-function to the six tests that actually spawn bash; the structural pin carries no such decorator and now runs (and was verified to still pass) even when BASH is None. Co-Authored-By: Max <noreply>
…slash ones
Windows CI (windows-latest, 3.10 and 3.12) went red on the four hook-level
tests: 4 failed / 700 passed. The failure was not inside resolve-paths.sh's
candidate logic at all -- it was session-start-hook.sh and user-prompt-hook.sh
failing to source their own sibling scripts ("./resolve-paths.sh: No such
file or directory", "./lib-clock.sh: No such file or directory") before
ever reaching REMEMBER_HOOK_CWD resolution.
Cause: this test file invoked each hook as `[BASH, str(script)]`, and
pathlib.Path.__str__ renders native separators -- backslashes on Windows.
session-start-hook.sh's self-location step, `_HOOK_DIR="${BASH_SOURCE[0]%/*}"`,
cannot derive a directory from a path with no forward slash in it, so every
`./sibling.sh` it then sources resolves against the wrong (unset/empty)
directory. This is a harness bug, not evidence against the #448 fix: real
hook dispatch never hands a hook a backslash-spelled $0 (hooks/hooks.json's
own command template is `"${CLAUDE_PLUGIN_ROOT}/scripts/session-start-hook.sh"`,
forward-slash, and this repo's own tests/test_hooks_json.py already
established forward-slash-always as its Windows-Git-Bash convention for
exactly this reason -- this file just failed to follow it).
Added `_win_bash_path()`, applied to the script argv and to HOME /
CLAUDE_PLUGIN_ROOT in `_env`, matching test_hooks_json.py's own
`.replace("\", "/")` convention. The REMEMBER_HOOK_CWD stdin payload value
itself is deliberately left native-spelled (str(project), unconverted) --
that native spelling is the actual thing #448's fix is about, and
converting it too would test nothing.
This is the first real Windows-CI-leg verdict this issue will get; nothing
in the previous two commits' local runs could exercise the platform
difference this fix targets.
Co-Authored-By: Max <noreply>
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.
Closes #448.
scripts/resolve-paths.shtestedREMEMBER_HOOK_CWDfor directory existence ([ -d ]) before the Windows backslash/drive-letter normalization block that would have made a Windows-native-spelledcwdresolvable -- that block only ever ran against whateverPROJECT_DIRhad already been selected, never againstREMEMBER_HOOK_CWDat the point it was tested. Acwdarriving with backslash separators or a bare drive letter was therefore tested in the form the shell cannot resolve, discarded, and resolution fell through to the loud failure -- silently, via each hook's own|| exit 0-- on a host with noCLAUDE_PROJECT_DIR(Codex, Gemini CLI, which is exactly when #411/#444'sREMEMBER_HOOK_CWDfallback is load-bearing).Fix: the normalization is now a function,
_remember_normalize_win_path, called on everyPROJECT_DIRcandidate before it is tested or selected, instead of once after a candidate was already chosen.CLAUDE_PROJECT_DIRgets the same normalize-then-trust treatment it always implicitly had (it was never-d-tested before selection either, only validated once at the very end).REMEMBER_HOOK_CWDkeeps its own existence test before selection, now against the normalized form, so a value that still doesn't resolve to a real directory falls through to the next candidate exactly as before, rather than being adopted and hard-failing later with a less specific message.Grade: reasoned, not observed -- found by reading, in a session with no Windows or Git Bash shell (the issue's own caveat). Settled by the Windows CI leg exercising the new tests, not by anything run in this session.
Tests:
tests/test_windows_native_hook_cwd_448.pycovers all four hooks that read this fallback (session-start-hook.sh, session-end-hook.sh since #411; user-prompt-hook.sh, post-tool-hook.sh since #444) viatests/_bash_runner.py'sresolve_bash()(#432/#439) so the Windows CI leg actually exercises it instead of skipping -- a blanket skip here would have reproduced the #442 defect (a Windows-only regression test skipped on the platform that could catch it) in the lane meant to fix a Windows bug. It also carries a platform-independent structural pin asserting theREMEMBER_HOOK_CWDexistence-test line in the source routes through the normalizer -- this is the one assertion that is provably red against the pre-fix source and green after, verified locally (both runs quoted in the agent report). The four hook-level 'resolves' tests pass identically before and after locally on macOS, since$OSTYPEnever triggers the msys/cygwin branch here; their own docstrings say so plainly rather than overclaiming coverage they don't have.Self-review: Explore reviewer returned
NO FINDINGS.oss:auditorreturned one finding -- the test file's original module-levelpytestmarkskip also silenced the structural pin, which has no bash dependency and doesn't need the skip; fixed in a second commit by moving the skip to a per-function_needs_bashmarker applied only to the six bash-dependent tests, verified by forcingresolve_bash()to returnNoneand confirming the pin still runs and passes while the six others report SKIPPED.Docs:
README.mdis this repo's onlydocs_targetsentry and is held by lane #437 -- not read, not touched.changelog.d/448.fixed.mdadded and validated against.oss/assemble_changelog.py --check(25 fragments, ok).Not touched:
scripts/session-start-hook.sh,scripts/session-end-hook.sh,scripts/user-prompt-hook.sh,scripts/post-tool-hook.sh,scripts/log.share read (the new tests run them as subprocesses) but not edited -- all four are held by sibling lanes #437/#450/#451 per the brief.fix/448, 2 commits, on top of origin/main @ 163bc51.