Skip to content

resolve-paths.sh tests REMEMBER_HOOK_CWD for directory existence before the Windows path normalization that would make it resolvable #448

Closed

Description

@fdaviddpt

Reported out of the #444 lane's self-review and routed here rather than fixed in that diff. Reasoned, not observed — no Windows or Git Bash shell was available in the session that found it, and that grade is part of the finding.

Symptom

On Windows, a hook payload's cwd that names a real directory can fail the existence test and be discarded, so resolve-paths.sh falls through to its next candidate or to the loud failure — on a host where CLAUDE_PROJECT_DIR is unset, that means every hook silently no-ops via its || exit 0.

Location

scripts/resolve-paths.sh:166:

elif [ -n "${REMEMBER_HOOK_CWD:-}" ] && [ -d "${REMEMBER_HOOK_CWD:-}" ]; then
    PROJECT_DIR="$REMEMBER_HOOK_CWD"

The backslash and drive-letter normalization block runs later, and only against whatever PROJECT_DIR was already chosen.

Mechanism

The ordering is test -d first, normalize second. A cwd arriving in a Windows-native spelling — backslash separators, or a bare drive letter — is therefore tested in the form the shell cannot resolve, and the branch is skipped before the code that would have fixed the spelling ever runs.

CLAUDE_PROJECT_DIR does not have this asymmetry, which is why it has never surfaced: on Claude Code the first candidate wins and the normalization it feeds is reached. #411 introduced the ordering when REMEMBER_HOOK_CWD existed on two hooks that only fire once per session. #444 extended the same variable to user-prompt-hook.sh and post-tool-hook.sh — the second of which runs on every tool call — so the blast radius grew without the ordering being revisited.

This is also the exact platform band this repo keeps getting caught by: a suffix or separator match that behaves differently with backslashes than with forward slashes, and a drive letter whose colon precedes the first slash.

What would settle it

A test that feeds each of the four hooks a cwd in Windows-native spelling with CLAUDE_PROJECT_DIR unset, and asserts the store is written rather than the FATAL path taken. It needs the Windows CI leg to be meaningful — tests/_bash_runner.py and resolve_bash() landed in #432/#439 and are what makes such a test runnable there rather than skipped, which is the piece that did not exist when #411 shipped.

Pair it with a positive control: an assertion that resolution succeeded passes just as well when the harness never ran the hook at all.

Activity

  1. added
    bug
    priority:medium
    on Aug 29, 2026
  2. self-assigned this
    on Aug 29, 2026
  3. added 2 commits that reference this issue on Aug 29, 2026
    70fcf3c
    f79f1c5
  4. added 3 commits that reference this issue on Sep 4, 2026
  5. added a commit that references this issue on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugpriority:medium

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions