fix(windows): unmangle MSYS Hermes paths - #39910
Conversation
|
Thanks for tracing a real Windows/MSYS failure. The premise is still present on current main: Problems
Suggested changes
This is an automated hermes-sweeper review. |
f27c863 to
5a19ce6
Compare
|
Addressed both problems from the hermes-sweeper review, plus one additional sibling route it pointed at. Rebased onto current P1 — normalizer no longer corrupts valid pathsThe old The "already-mangled Regression added on every surface asserting P2 — sibling identity / store routesAdded a shared
Also made Out of scope for this PR (different semantics — noted for a follow-up): VerificationBehavior on POSIX (where CI runs) is unchanged: |
5a19ce6 to
86e529d
Compare
|
CI follow-up: fixed the sole failing check from run Failure
This was a real cross-platform simulation regression introduced by the Windows branch in the root resolver, not a flaky test. FixWhen the active Regression and verification
New CI is running on |
…\c\... Native CPython launched from git-bash/MSYS can receive Hermes paths as /c/..., /cygdrive/c/..., or /mnt/c/..., which Path.resolve()/os.path.abspath() then bind to the current drive (C:\c\...), creating a second Hermes tree for HERMES_HOME, the cron stores, gateway identity files, and rotating logs. - normalize_windows_msys_path(): translate ONLY the unambiguous MSYS POSIX drive forms; preserve a legitimate native C:\c\work byte-for-byte. The earlier heuristic that stripped a drive-letter tail component corrupted valid paths (maintainer review P1). - canonicalize_hermes_path(): MSYS-safe stable-path helper that avoids Windows Path.resolve()/abspath; byte-identical to the prior resolve() behavior on POSIX. - Route HERMES_HOME, %LOCALAPPDATA% fallback, profile-root comparison, the cron jobs/suggestions/executions stores, gateway PID/lock/status identity, and rotating-log path identity through the safe handling (review P2). The rotating-log handler restores the caller's requested path after abspath rather than guessing at an un-mangle of the ambiguous C:\c\... form. - get_default_hermes_root() profile detection uses ntpath string ops so a native C:\...\profiles\name path is parsed correctly. Adds regressions across every surface asserting C:\c\... is preserved and raw MSYS forms are translated. Fixes NousResearch#39834. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
86e529d to
6e4fbc1
Compare
# Conflicts: # tests/test_hermes_logging.py
Summary
normalize_windows_msys_path) that translates the unambiguous MSYS/git-bash drive forms (/c/...,/cygdrive/c/...,/mnt/c/...) to nativeC:\..., and acanonicalize_hermes_pathhelper that produces a stable path without WindowsPath.resolve()/os.path.abspath().C:\c\workis preserved byte-for-byte — it cannot be structurally distinguished from a mangled path, so it is never rewritten. The "already-mangledC:\c\..." rotating-log case is handled by preventing the mangle (restoring the caller's requested path afterabspath), not by guessing at an un-mangle.HERMES_HOME,%LOCALAPPDATA%fallback, profile-root comparison, the cron jobs/suggestions/executions stores, gateway PID/lock/status identity, and rotating-log path identity through the safe handling.Fixes #39834.
Verification
.venv/bin/python -m py_compile hermes_constants.py hermes_logging.py cron/jobs.py cron/suggestions.py cron/executions.py gateway/status.py.venv/bin/python -m pytest tests/test_hermes_constants.py tests/test_hermes_logging.py tests/cron/test_jobs.py tests/cron/test_suggestions.py tests/cron/test_execution_ledger.py tests/gateway/test_status.py -q -o addopts=→ 531 passedruff checkon all touched files → cleanpython scripts/check-windows-footguns.py --all→ no footguns (809 files)git diff --check