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
{{ message }}
Repository navigation
refactor(pathfinder): search steps read the resolved search context - #3606
The search steps now read plain fields from the SearchContext record added in the previous change, instead of calling through a platform object. This removes the SearchPlatform protocol, both platform classes, the PLATFORM singleton, and the two copies of the site-packages finder (one per platform).
search_platform.py goes from 339 to 180 lines. The one remaining platform branch is in _find_lib_file, where the real difference lives: which file names to try, and the Windows DLL checks.
Tests: construction changes only. platform=WindowsSearchPlatform(target_arch="x64") becomes windows_arch="x64". Six assertions read the same value from the context instead of from the platform object; the expected values are unchanged. The comparison test from the previous change is removed with the classes it compared against.
Also in this PR: pin the not-found error text before the refactor.
test_not_found_error_lists_every_miss_in_search_order pins the full DynamicLibNotFoundError text for a library that misses everywhere. It passes on this code unchanged. #3607 rewrites how misses are reported and does not touch this test, so CI shows the text is the same before and after.
No behavior change. 1646 passed, 6 skipped.
Testing
Full cuda_pathfinder test suite at this commit: 1646 passed, 6 skipped (Linux, Python 3.14).
pre-commit clean, including mypy-pathfinder.
Not run on Windows. Windows rules are exercised by tests that simulate Windows on Linux.
PLC Local Security Evidence (Advisory)
Local advisory checks only, run over the whole stack. Not release-gate results.
Check
Status
Tool
Details
Secrets
SKIP
Pulse Secret Scanner
scanner image not available locally (registry login); the repo trufflehog pre-commit hook passed
SAST
WARN
Semgrep
1 finding, not from this stack: the existing subprocess.run call in the canary probe in load_nvidia_dynamic_lib.py
Dependencies
WARN
pip-audit / osv-scanner
no manifest or lockfile in scope, so the local scan could not run; this stack changes no dependencies
Reviewing files that changed from the base of the PR and between 72adfbe and 67d9896.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Bug Fixes
Library search failures now distinguish between missing directories and directories without an architecture-compatible library.
Search diagnostics list failed locations in search order and include directory contents when available, making it easier to understand where a library search failed.
Refactor
Updated the library-search flow while preserving platform-specific lookup behavior and the information provided when a library cannot be found.
Platform-specific library search settings and lookup functions now use SearchContext. Search steps, the library loader, and tests use context factories and properties.
Changes: Dynamic library search
Layer / File(s)
Summary
Search context and lookup cuda_pathfinder/cuda/pathfinder/_dynamic_libs/search_platform.py, cuda_pathfinder/tests/test_ctk_root_discovery.py
SearchContext now holds platform-specific search settings and diagnostic details. Shared functions select soname or DLL lookup, search configured directories, and record failure details. A test checks that not-found errors list misses in search order and include directory listings.
Search routing and context adoption cuda_pathfinder/cuda/pathfinder/_dynamic_libs/search_steps.py, cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_nvidia_dynamic_lib.py, cuda_pathfinder/tests/*
Search steps now read search settings from the context and call shared lookup functions. The loader creates contexts with search_context. Tests use platform-specific context factories and retain search assertions. The former SearchPlatform implementations and the SearchContext definition in search_steps.py were removed.
Suggested reviewers:cpcloud
Change: Refactor
Merge Risk: Minimal · previous review 40874
This refactor keeps the dynamic library search behavior unchanged and moves platform rules into one context-based design. No merge-blocking issue was found, and Linux tests pass. Windows paths are checked only by simulation on Linux.
Security architecture risk: Minimal · up to 40874
CUDA Pathfinder now resolves platform search settings once per library search and passes them to the search steps. The reviewed change preserves search precedence, Windows DLL checks, and the public loading API. No expanded loading authority or new operator action was identified.
Security review details
Security Blast Radius
inferred — The changed lookup helpers affect native-library selection within the calling Python process. The inspected change does not add a caller-supplied search root to the public API or introduce a service or privilege boundary.
Trust Boundaries and Controls
observed — Candidate paths still come from the installed package layout, existing process environment settings, and native loader search. In the Windows filesystem search, the shared helper still requires an existing descriptor-named file, rejects suppressed DLLs, and checks PE architecture where the descriptor requires it. These are candidate-selection checks, not authenticity checks.
Data and control flow
observed — Driver libraries still bypass the toolkit search. For other libraries, the loader retains the already-loaded checks, wheel and Conda search, native system search, late filesystem search, and descriptor-configured canary fallback. A discovered path still goes to the existing platform loader.
Resilience and Maintainability Implications
observed — The shared helpers retain per-search diagnostics. An OSError while listing a directory for miss diagnostics is recorded rather than aborting discovery. That continuation guarantee applies to the diagnostic listing; it does not mean that a later native-load failure is treated as another miss.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 1 remain after this review.
The search steps now read plain fields from the `SearchContext` record
added in the previous change, instead of calling through a platform
object. This removes the `SearchPlatform` protocol, both platform
classes, the `PLATFORM` singleton, and the two copies of the
site-packages finder (one per platform).
`search_platform.py` goes from 339 to 180 lines. The one remaining
platform branch is in `_find_lib_file`, where the real difference lives:
which file names to try, and the Windows DLL checks.
Tests: construction changes only. `platform=WindowsSearchPlatform(
target_arch="x64")` becomes `windows_arch="x64"`. Assertions are
unchanged. The comparison test from the previous change is removed
with the classes it compared against.
No behavior change. 1645 passed, 6 skipped.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Rob Parolin <rparolin@nvidia.com>
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
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.
— codex on behalf of Ralf —
Description
Part 6 of 23 of a readability stack for
cuda.pathfinder(stack: #3623 → #3602 → #3603 → #3604 → #3605 → #3606 → #3607 → #3608 → #3609 → #3610 → #3611 → #3613 → #3618 → #3619 → #3620 → #3621 → #3622 → #3627 → #3628 → #3629 → #3630 → #3631 → #3632). No behavior change.The search steps now read plain fields from the
SearchContextrecord added in the previous change, instead of calling through a platform object. This removes theSearchPlatformprotocol, both platform classes, thePLATFORMsingleton, and the two copies of the site-packages finder (one per platform).search_platform.pygoes from 339 to 180 lines. The one remaining platform branch is in_find_lib_file, where the real difference lives: which file names to try, and the Windows DLL checks.Tests: construction changes only.
platform=WindowsSearchPlatform(target_arch="x64")becomeswindows_arch="x64". Six assertions read the same value from the context instead of from the platform object; the expected values are unchanged. The comparison test from the previous change is removed with the classes it compared against.Also in this PR: pin the not-found error text before the refactor.
test_not_found_error_lists_every_miss_in_search_orderpins the fullDynamicLibNotFoundErrortext for a library that misses everywhere. It passes on this code unchanged. #3607 rewrites how misses are reported and does not touch this test, so CI shows the text is the same before and after.No behavior change. 1646 passed, 6 skipped.
Testing
cuda_pathfindertest suite at this commit: 1646 passed, 6 skipped (Linux, Python 3.14).mypy-pathfinder.PLC Local Security Evidence (Advisory)
Local advisory checks only, run over the whole stack. Not release-gate results.
subprocess.runcall in the canary probe inload_nvidia_dynamic_lib.pyChecklist
🤖 Generated with Claude Code