Add FlashMLA flashmla runtime path audit#26
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new Python script, tools/runtime_path_audit.py, designed to audit MACA-related environment path variables for duplicate or non-existent entries. Feedback on the implementation suggests using os.path.normpath to ensure redundant path segments are fully normalized when checking for duplicates, and replacing the assert statement in the self-test with an explicit conditional check and exception to prevent it from being bypassed under Python optimization flags.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| for name in ENV_VARS: | ||
| seen: set[str] = set() | ||
| for raw in split_paths(env.get(name, "")): | ||
| normalized = str(Path(raw)) |
There was a problem hiding this comment.
Using str(Path(raw)) does not fully normalize redundant path segments like . or .. (for example, /usr/local/lib/../lib is not collapsed). To reliably detect duplicate entries regardless of formatting, use os.path.normpath(raw) instead.
| normalized = str(Path(raw)) | |
| normalized = os.path.normpath(raw) |
| def self_test() -> None: | ||
| missing = os.pathsep.join(["/definitely_missing", "/definitely_missing"]) | ||
| data = audit({"LD_LIBRARY_PATH": missing}) | ||
| assert data["finding_count"] >= 2 |
There was a problem hiding this comment.
Using assert statements for runtime validation or self-tests is discouraged in production code because they can be globally disabled when Python is run with optimization flags (e.g., python -O). Instead, use an explicit conditional check and raise an appropriate exception (like RuntimeError).
| assert data["finding_count"] >= 2 | |
| if data["finding_count"] < 2: | |
| raise RuntimeError(f"Self-test failed: expected at least 2 findings, got {data['finding_count']}") |
- Add FlashMLA runtime path audit - Normalize runtime path audit entries
Summary
Validation
Review notes