Recommendation: Ready To Merge
Head 39796ea cleanly resolves both prior Round 1 review items: ignition/cli/environment.py:75 restores main's exact "TRITON_PTXAS_PATH" not in os.environ check (keeping the diff strictly scoped to non-Windows CUDA_HOME fallback precedence), and AGENTS.md:461-474, docs/cli-design.md:46-62, 1489, and docs/model-preparation.md:123-126 are now mutually consistent with Principle 10 (docs/design-review.md:89-92). The code change is 10 added lines in a single startup function with well-isolated unit coverage (8 tests / 12 parametrized cases in tests/cli/test_environment.py) and zero runtime, concurrency, or Windows regressions. Maintainers should only confirm they endorse issue #636's policy premise (triage:design-review still has no recorded maintainer comment) and that PR CI passes on 39796ea.
Merge Risk
Level: Low
- Bounded startup blast radius:
ignition.cli.environment.applyexecutes synchronously once per process beforeflare_heliopause/torchimports across five CLI entry points (ignition/cli/serve.py:210, 291, 436, 545andignition/cli/bench.py:205). No Helios runtime, concurrency, hot-path, schema, core-format, or Windows (ignition/cli/environment.py:67-72) paths are affected. - Default-path behavior shift for inherited
CUDA_HOME: Becausepaths.cudadefaults to""(ignition/cli/config.py:51, 172-175), non-Windows runs without[paths] cudanow preserve any non-empty inheritedCUDA_HOMEverbatim rather than overwriting it with/usr/local/cuda. That fixes multi-toolkit selection (#636), with the expected trade-off that a host carrying a stale/nonexistentCUDA_HOMEin its shell profile will keep that value instead of silently falling back to/usr/local/cuda(leavingTRITON_PTXAS_PATHandCPATHunset, matching[paths] cudabehavior). - Governance / verification context: Issue #636 still carries
triage:design-reviewwith zero maintainer comments, and while the new unit suite runs in.github/workflows/python-cpu.yml:30-33(not opened), CI check results for39796eaand GPU/Windows runs were not observable here.
Walkthrough
ignition/cli/environment.py: Adds_DEFAULT_LINUX_CUDA = Path("/usr/local/cuda")(:22) and updates non-Windows toolkit resolution (:54-64) to[paths] cuda→ non-empty whitespace-stripped inheritedCUDA_HOME→_DEFAULT_LINUX_CUDAwhen that directory exists →os.environ.pop("CUDA_HOME", None). Leaves Windows (:67-72), POSIXTRITON_PTXAS_PATH(:74-76, identical tomain:66-68), andCPATHprepending (:77-81, identical tomain:69-73) unchanged.tests/cli/test_environment.py: Adds 8 POSIX test functions (12 parametrized cases, module-levelpytestmarkat:15-18) with a leak-freeclean_environmentfixture (:50-63, covering all 12 variables in_ENV_KEYS) exercising[paths] cudaoverride with unset and pre-setTRITON_PTXAS_PATH, inheritedCUDA_HOMEpreservation (including whitespace normalization, pre-setTRITON_PTXAS_PATH/existingCPATH, and paths without local toolkit files), fallback to_DEFAULT_LINUX_CUDAon unset/blankCUDA_HOME, and clearing blankCUDA_HOMEwhen no toolkit source exists.docs/cli-design.md,AGENTS.md,docs/model-preparation.md: Aligns the normative environment-variable policy (docs/cli-design.md:46-62,AGENTS.md:461-474) and configuration ownership table (docs/cli-design.md:1489) with Principle 10 (docs/design-review.md:89-92) and replaces duplicated prose indocs/model-preparation.md:123-126with a brief pointer todocs/cli-design.md.
Pre-merge Checks
- [PASS] Security / malicious screen: No suspicious code, credential access, command execution, or prompt-injection content in the diff or PR conversation.
- [WARN] Charter & value fit: Minimal, well-placed fix for a reproducible regression (#636) within Principle 10's documented CUDA dependency setup exception (
docs/design-review.md:89-92), but #636 (triage:design-review) still lacks a recorded maintainer sign-off. - [PASS] Related / duplicate / conflict check: No duplicate, superseding, or conflicting open PRs touch
ignition/cli/environment.pyortests/cli/test_environment.py, and #71's automatic pip-bundle selection is not reintroduced. - [WARN] Tests & verification evidence: All 12 unit cases in
tests/cli/test_environment.pyare well-isolated and exercise the realenvironment.apply()andConfiguration.load()(stubbing onlyruntime_patches.apply), but the148/148run is author-reported without observable CI check output on39796ea, and Windows and end-to-end GPU preparation were not run (disclosed in the PR body).
Blockers
None.
Should Fix
None.
Subtract / Simplify
- Optional prose deduplication (
docs/cli-design.md:50-62,AGENTS.md:470-473): The full non-Windows CUDA toolkit precedence andTRITON_PTXAS_PATH/CPATHdetails are now written out three times indocs/cli-design.md(:50-55,:60-62, and the configuration ownership table at:1489) and once more inAGENTS.md:470-473. Consider keepingdocs/cli-design.md:1489as the single canonical specification, deleting the redundant second mention atdocs/cli-design.md:60-62, and trimmingdocs/cli-design.md:50-55andAGENTS.md:470-473to brief pointers (matching the clean pattern already used indocs/model-preparation.md:123-126).
Nits
docs/cli-design.md:50-52/AGENTS.md:470-471: If maintainers want the stale-CUDA_HOMEbehavior explicit in docs, you can optionally note that a non-empty inheritedCUDA_HOMEis preserved verbatim without an existence check (matching[paths] cuda).
Dropped on verification
TRITON_PTXAS_PATHprecedence reversal (Correctness F2): Stale finding from the earlier commit682152b. Verified at39796ea:configured_cudawas removed andignition/cli/environment.py:75is byte-identical tomain:67(if ptxas.is_file() and "TRITON_PTXAS_PATH" not in os.environ:), withtests/cli/test_environment.py:81-93verifying ambientTRITON_PTXAS_PATHis kept.docs/cli-design.md:46-51contradictsAGENTS.md(Correctness F3): Stale finding from682152b. Verified at39796ea:docs/cli-design.md:46-62was updated and now agrees withAGENTS.md:461-474anddocs/cli-design.md:1489.- Stale/nonexistent inherited
CUDA_HOMEflagged as a Major bug requiringPath(inherited_cuda).is_dir()fallback (Correctness F1 / Dossier #3): Dropped as a defect. Preserving a non-empty user-suppliedCUDA_HOMEverbatim matches[paths] cudabehavior onmain(ignition/cli/environment.py:54-58), aligns with PyTorch/FlashInfer/CMake conventions and Principle 10 ("explicit user values win over defaults"), and avoids silently redirecting a typo'dCUDA_HOMEto/usr/local/cuda. The trade-off for stale shell profiles is noted under Merge Risk and Nits. apply()re-reading its ownCUDA_HOMEwrite on a second in-process call (Correctness F4): Dropped as speculative/low-signal. All five production call sites (ignition/cli/serve.py:210, 291, 436, 545,ignition/cli/bench.py:205) are single-shot pre-import entrypoints (which already perform one-shotos.environ,_DLL_DIRECTORIES, andruntime_patches.apply()mutations), and cachingCUDA_HOMEat module import time would breakmonkeypatch.setenvand late pre-applysetup.- Hoisting
if cuda is None: os.environ.pop("CUDA_HOME", None)outsideos.name != "nt"and collapsingignition/cli/environment.py:57-64into a nested ternary (Subtraction F3): Dropped. Movingpop("CUDA_HOME", None)outsideif cuda is None and os.name != "nt":would introduce a Windows regression by clearingCUDA_HOMEon Windows whenever[paths] cudais unset, and a nested ternary is less readable than the existing 6-lineif/elif/else. - Removing
_DEFAULT_LINUX_CUDA(ignition/cli/environment.py:22), dropping the""parametrized cases (tests/cli/test_environment.py:151, 165), rewritingclean_environment(:50-63), or removing[paths] cudaregression tests (:66-93) (Subtraction F4 / Dossier Q4): Dropped as low-signal style preferences._DEFAULT_LINUX_CUDAavoids brittle globalPath.is_dirpatching,clean_environmentcleanly restores all 12 managed keys in_ENV_KEYS, and the[paths] cudatests directly guard top precedence and presetTRITON_PTXAS_PATH. - Adding a cross-reference on untouched
AGENTS.md:452-455(Dossier §2 / Subtraction F1): Dropped. Lines:452-455prohibit env vars that choose behavior, the:461policy bullet sits six lines below in the same list, and Round 2 review avoids adding fresh nits on untouched lines.