Skip to content

feat(platform): add cross-platform filelock, procutil, env, and wincred primitives - #270

Merged
ZLHad merged 2 commits into
mainfrom
codex/cross-platform-primitives
Dec 3, 2026
Merged

ZLHad merged 2 commits into
mainfrom
codex/cross-platform-primitives

Conversation

@ZLHad

@ZLHad ZLHad commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Summary

Establishes stdlib-only cross-platform foundation primitives under tools/ as the first step toward native Windows support, while keeping POSIX behavior unchanged and adding automated AST and behavioral guards:

  • tools/ovh_filelock.py: Advisory locking (fcntl.flock on POSIX; Win32 LockFileEx/UnlockFileEx on Windows with CancelIoEx guard) and root-confined open_nofollow / unlink_nofollow / rmdir_nofollow (POSIX dir_fd + O_NOFOLLOW; Win32 pinned parent handles + FILE_FLAG_OPEN_REPARSE_POINT + GetFinalPathNameByHandleW + SetFileInformationByHandle). Named ovh_filelock so tools/ on sys.path[0] never shadows PyPI filelock imported by huggingface_hub.
  • tools/procutil.py: Cross-platform alive (WaitForSingleObject avoiding STILL_ACTIVE=259), start_time, handle-pinned process_info + PowerShell CIM CreationDate correlation, descendants_info, find_ancestor, process_name, has_ancestor_cmd, ProcessTreeGuard (Win32 Job Object), identity-bound send_signal, and System32-pinned win_system_exe.
  • tools/platform_env.py: Cross-platform config_dir / cache_dir (XDG > APPDATA/LOCALAPPDATA > home), CWD-safe which() and Chrome/Chromium/Edge discovery, and Windows/Linux/macOS font_folders().
  • tools/keys.py: Windows Credential Manager (wincred) backend via advapi32.dll (ctypes, UTF-8 blobs supporting full 2,048-char keys, distinguishing ERROR_NOT_FOUND from real Win32 errors); updated tools/schemas/output/settings-keys.schema.json and docs/project-format.md.
  • Call-site migrations: settings, history, versions, clean, activity, standing, cancel, fonts, hf, web, assets/{budget,ledger,image}, audio/mixstate, scout/refs, and bin/vh.
  • CI & regression guards: Added tools/ci/py/static_checks/portable_primitives.py (AST regression guard + behavioral tests) and a native windows-primitives job on windows-latest in .github/workflows/ci.yml.

Verification

  • Core tools/ci.sh --committed (all 43 groups, /bin/bash 3.2, shellcheck): all checks passed
  • pyflakes on all modified/added Python modules & huggingface_hub non-shadowing import check: clean
  • Independent multi-pass code review (codex gpt-6.2-sol (max)): all High/Medium/Low findings addressed
  • GitHub Actions windows primitives (windows-latest) + Linux/macOS required checks: pending on this Draft PR

ZLHad added 2 commits December 3, 2026 03:15
…ed primitives

Introduce stdlib-only cross-platform foundation modules under tools/ so Windows
and POSIX share one tested contract without altering POSIX behavior:
- tools/ovh_filelock.py: POSIX fcntl.flock + Win32 LockFileEx/UnlockFileEx,
  plus root-confined open_nofollow / unlink_nofollow / rmdir_nofollow (named
  ovh_filelock so tools/ on sys.path never shadows PyPI filelock).
- tools/procutil.py: cross-platform alive, start_time, process_info,
  descendants_info, find_ancestor, ProcessTreeGuard (Win32 Job Object),
  identity-bound send_signal, and System32-pinned win_system_exe.
- tools/platform_env.py: cross-platform config_dir/cache_dir, CWD-safe which
  and Chrome/Edge discovery, and Windows/Linux/macOS font_folders.
- tools/keys.py: Windows Credential Manager (wincred) backend via advapi32.dll
  using UTF-8 blobs with strict error propagation; update schema & docs.
- Migrate all 7 fcntl/O_NOFOLLOW/killpg/ps/XDG/Chrome/font call sites across
  tools/ and add AST regression guard, cross-platform tests, and a native
  windows-primitives CI job.
@ZLHad
ZLHad marked this pull request as ready for review December 3, 2026 03:09
@ZLHad
ZLHad enabled auto-merge (squash) December 3, 2026 03:09
@ZLHad
ZLHad merged commit 17f4178 into main Dec 3, 2026
5 checks passed
@ZLHad
ZLHad deleted the codex/cross-platform-primitives branch December 3, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant