You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Windows + macOS CI matrix expansion (#634) skips three test classes
in `packages/memtomem/tests/test_runtime_paths.py` on Windows:
`TestRuntimeDir`
`TestEnsureRuntimeDir`
`TestServerPidPath`
These classes assume POSIX semantics that don't translate cleanly to
NTFS:
The shared `_make_safe_xdg` fixture does `os.chmod(xdg, 0o700)` to
set up the XDG base. NTFS reports synthesized POSIX mode bits
(typically `0o666` or `0o777`) that don't match `0o700`, so
`_is_safe_dir` (which checks `S_IMODE(st.st_mode) & 0o077`) would
reject the directory and the XDG branch silently falls through to the
tempdir form — breaking the tests that assert the XDG path is used.
`TestEnsureRuntimeDir.test_creates_directory_with_owner_only_mode`
asserts `S_IMODE(d.stat().st_mode) == 0o700`, which is POSIX-only.
`TestEnsureRuntimeDir.test_explicit_chmod_survives_wild_umask` uses
`os.umask(0o177)`, which Windows ignores.
`TestEnsureRuntimeDir.test_refuses_existing_loose_mode` depends on
the `0o755` vs `0o700` distinction.
The runtime code itself
(`packages/memtomem/src/memtomem/_runtime_paths.py`) already has a
Windows-aware path through `tempfile.gettempdir()` + `uid=0` (the
`os.geteuid()` calls are `hasattr`-guarded), but its behavior on
NTFS is unverified today — that's what this issue tracks.
Scope
Verify `runtime_dir()` and `ensure_runtime_dir()` behave correctly
on Windows: pid file lands at `%LOCALAPPDATA%\Temp\memtomem-0`
(or whatever `tempfile.gettempdir()` returns), `ensure_runtime_dir()`
doesn't raise on a fresh runner, and validation doesn't no-op away
the security guarantees we care about.
Decide the NTFS security contract. Options:
Relax `_is_safe_dir` on Windows (accept the kernel default).
Use `os.access(path, os.W_OK)` + owner-SID checks via stdlib
`os.stat()` + `stat.FILE_ATTRIBUTE_*` (or `pywin32` if needed).
Document Windows as best-effort and skip mode-bit validation.
Either rewrite the three skipped classes to be Windows-aware, or
add a separate `TestRuntimeDir{Windows,Posix}` split with native
assertions per platform.
Out of scope: changing the runtime code's POSIX contract. The pid-file
location and ownership semantics on Windows are an open design
question that this issue should decide before relaxing anything.
Background
The Windows + macOS CI matrix expansion (#634) skips three test classes
in `packages/memtomem/tests/test_runtime_paths.py` on Windows:
These classes assume POSIX semantics that don't translate cleanly to
NTFS:
set up the XDG base. NTFS reports synthesized POSIX mode bits
(typically `0o666` or `0o777`) that don't match `0o700`, so
`_is_safe_dir` (which checks `S_IMODE(st.st_mode) & 0o077`) would
reject the directory and the XDG branch silently falls through to the
tempdir form — breaking the tests that assert the XDG path is used.
asserts `S_IMODE(d.stat().st_mode) == 0o700`, which is POSIX-only.
`os.umask(0o177)`, which Windows ignores.
the `0o755` vs `0o700` distinction.
The runtime code itself
(`packages/memtomem/src/memtomem/_runtime_paths.py`) already has a
Windows-aware path through `tempfile.gettempdir()` + `uid=0` (the
`os.geteuid()` calls are `hasattr`-guarded), but its behavior on
NTFS is unverified today — that's what this issue tracks.
Scope
on Windows: pid file lands at `%LOCALAPPDATA%\Temp\memtomem-0`
(or whatever `tempfile.gettempdir()` returns), `ensure_runtime_dir()`
doesn't raise on a fresh runner, and validation doesn't no-op away
the security guarantees we care about.
`os.stat()` + `stat.FILE_ATTRIBUTE_*` (or `pywin32` if needed).
add a separate `TestRuntimeDir{Windows,Posix}` split with native
assertions per platform.
Out of scope: changing the runtime code's POSIX contract. The pid-file
location and ownership semantics on Windows are an open design
question that this issue should decide before relaxing anything.
References
resolver + `ensure_runtime_dir`
currently skipped on Windows
🤖 Generated with Claude Code