Repository navigation
feat(platform): add cross-platform filelock, procutil, env, and wincred primitives - #270
Merged
Merged
Conversation
…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
marked this pull request as ready for review
December 3, 2026 03:09
ZLHad
enabled auto-merge (squash)
December 3, 2026 03:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.flockon POSIX; Win32LockFileEx/UnlockFileExon Windows withCancelIoExguard) and root-confinedopen_nofollow/unlink_nofollow/rmdir_nofollow(POSIXdir_fd+O_NOFOLLOW; Win32 pinned parent handles +FILE_FLAG_OPEN_REPARSE_POINT+GetFinalPathNameByHandleW+SetFileInformationByHandle). Namedovh_filelocksotools/onsys.path[0]never shadows PyPIfilelockimported byhuggingface_hub.tools/procutil.py: Cross-platformalive(WaitForSingleObjectavoidingSTILL_ACTIVE=259),start_time, handle-pinnedprocess_info+ PowerShell CIMCreationDatecorrelation,descendants_info,find_ancestor,process_name,has_ancestor_cmd,ProcessTreeGuard(Win32 Job Object), identity-boundsend_signal, and System32-pinnedwin_system_exe.tools/platform_env.py: Cross-platformconfig_dir/cache_dir(XDG >APPDATA/LOCALAPPDATA> home), CWD-safewhich()and Chrome/Chromium/Edge discovery, and Windows/Linux/macOSfont_folders().tools/keys.py: Windows Credential Manager (wincred) backend viaadvapi32.dll(ctypes, UTF-8 blobs supporting full 2,048-char keys, distinguishingERROR_NOT_FOUNDfrom real Win32 errors); updatedtools/schemas/output/settings-keys.schema.jsonanddocs/project-format.md.settings,history,versions,clean,activity,standing,cancel,fonts,hf,web,assets/{budget,ledger,image},audio/mixstate,scout/refs, andbin/vh.tools/ci/py/static_checks/portable_primitives.py(AST regression guard + behavioral tests) and a nativewindows-primitivesjob onwindows-latestin.github/workflows/ci.yml.Verification
tools/ci.sh --committed(all 43 groups,/bin/bash3.2,shellcheck): all checks passedpyflakeson all modified/added Python modules &huggingface_hubnon-shadowing import check: cleancodexgpt-6.2-sol (max)): all High/Medium/Low findings addressedwindows primitives (windows-latest)+ Linux/macOS required checks: pending on this Draft PR