Problem
tests/Test-Hooks.ps1 compares the expected verify-hook working directory with paths recorded by child pwsh processes. Those strings can name the same physical directory differently across process and platform boundaries.
On macOS, [System.IO.Path]::GetTempPath() can return /var/folders/..., while a child process reports the same directory as /private/var/folders/... because /var resolves to /private/var. Raw string equality therefore fails the five CWD scenario assertions even though every verify hook ran in the intended directory.
Windows has the equivalent risk when one path uses an 8.3 short-name alias and another uses the long path, such as C:\PROGRA~1 versus C:\Program Files. Ordinary separator, trailing-separator, and case representation also need platform-appropriate treatment.
Required behavior
- Compare canonical filesystem locations, not raw path spellings.
- Resolve macOS
/var/... and /private/var/... as the same physical path through filesystem-aware canonicalization; do not hard-code a /private string prefix.
- On Windows, expand short/long path aliases where the filesystem and runtime expose a canonical path, and use Windows-appropriate case comparison.
- Keep canonicalization at the test comparison boundary; do not change production hook execution behavior as part of this issue.
- Retain useful failure diagnostics showing the original recorded paths and the canonical values used for comparison.
Semantic acceptance criteria
- The verify chain must still record exactly five marker entries.
- Every recorded marker must canonicalize to the intended expected directory.
- All five recorded markers must canonicalize to one consistent directory.
- A genuinely different directory must still fail the assertion; canonicalization must not become substring, suffix, or existence-only matching.
- Paths that cannot be resolved must fail clearly rather than silently falling back to a weaker comparison.
Required coverage
- A macOS test exercises equivalent
/var/folders/... and /private/var/folders/... paths and passes only after physical-path canonicalization.
- Windows coverage exercises short/long aliases when 8.3 aliases are available, with a safe platform skip when they are not.
- Existing CWD scenarios continue to cover valid worktree selection, alternate provenance shape, stale worktree fallback, standalone working-directory selection, and final fallback.
pwsh tests/Test-Hooks.ps1 passes.
- Relevant PowerShell parser/structure and process-dispatch tests pass.
pwsh tests/Run-Tests.ps1 layers 1–3 pass.
- Required macOS, Ubuntu, and Windows CI jobs all complete successfully before merge.
Problem
tests/Test-Hooks.ps1compares the expected verify-hook working directory with paths recorded by childpwshprocesses. Those strings can name the same physical directory differently across process and platform boundaries.On macOS,
[System.IO.Path]::GetTempPath()can return/var/folders/..., while a child process reports the same directory as/private/var/folders/...because/varresolves to/private/var. Raw string equality therefore fails the five CWD scenario assertions even though every verify hook ran in the intended directory.Windows has the equivalent risk when one path uses an 8.3 short-name alias and another uses the long path, such as
C:\PROGRA~1versusC:\Program Files. Ordinary separator, trailing-separator, and case representation also need platform-appropriate treatment.Required behavior
/var/...and/private/var/...as the same physical path through filesystem-aware canonicalization; do not hard-code a/privatestring prefix.Semantic acceptance criteria
Required coverage
/var/folders/...and/private/var/folders/...paths and passes only after physical-path canonicalization.pwsh tests/Test-Hooks.ps1passes.pwsh tests/Run-Tests.ps1layers 1–3 pass.