#1 [high] F1 Major: stale/nonexistent inherited CUDA_HOME silently disables toolkit env (no existence check)
Code (head 39796ea, pr/690), ignition/cli/environment.py:56-66:
cuda = configuration.directory("cuda")
if cuda is None and os.name != "nt":
inherited_cuda = os.environ.get("CUDA_HOME", "").strip()
if inherited_cuda:
cuda = Path(inherited_cuda)
elif _DEFAULT_LINUX_CUDA.is_dir():
cuda = _DEFAULT_LINUX_CUDA
else:
os.environ.pop("CUDA_HOME", None)
if cuda is not None:
os.environ["CUDA_HOME"] = str(cuda)
No is_dir() / bin/ptxas existence check on the inherited value (contrast the /usr/local/cuda branch at :61 which does check is_dir()). Then :74-81 skip both derivations because bin/ptxas is not a file and include is not a dir.
Test freezing it, tests/cli/test_environment.py:138-148:
def test_inherited_cuda_home_without_local_files_does_not_fall_back_to_default(...):
inherited = clean_environment / "custom-cuda" # never created
default = _make_toolkit(clean_environment / "default-cuda")
monkeypatch.setattr(environment, "_DEFAULT_LINUX_CUDA", default)
monkeypatch.setenv("CUDA_HOME", str(inherited))
environment.apply(_load_config(clean_environment), ())
assert os.environ["CUDA_HOME"] == str(inherited)
assert "TRITON_PTXAS_PATH" not in os.environ
assert "CPATH" not in os.environ
Impact: on a host that previously worked via /usr/local/cuda (main:55-56 if cuda is None and os.name != "nt" and Path("/usr/local/cuda").is_dir(): cuda = Path("/usr/local/cuda")), a stale/leftover exported CUDA_HOME (shell profile, container env, another toolkit) now overrides the working default and yields no TRITON_PTXAS_PATH/CPATH at all — strictly worse than main for that host, and the mirror image of #636. Downstream consumer of the poisoned value: ignition/preparation/kv_codec.py:21-38 _find_nvcc() reads from torch.utils.cpp_extension import CUDA_HOME (which derives from this env var) as its first candidate -> RuntimeError "nvcc is required during core export". Docs do not disclose the no-existence-check rule: docs/cli-design.md:50-53 "preserves a non-empty inherited CUDA_HOME before falling back to /usr/local/cuda" and :60-62 "falls back through inherited CUDA_HOME and /usr/local/cuda" both read as validated fallback chains. AGENTS.md:470-471 same.
Fix: if inherited_cuda and Path(inherited_cuda).is_dir(): so a nonexistent path continues to the /usr/local/cuda branch, or (if as-is is intended) state in docs/cli-design.md:50-52 and AGENTS.md:470 that a non-empty inherited CUDA_HOME is used verbatim without an existence check, and drop/adjust the test asserting the no-op.
#3 [high] Verified-unchanged / no-finding areas + test & CI facts
Verified at pr/690 against main:
- Windows branch unchanged: environment.py:67-72 == main:59-64 byte-for-byte;
os.name == "nt"still skips all new logic (>:57cuda is None and os.name != "nt"). PR text's "Windows behavior unchanged" is accurate by inspection; still untested (module-level skip tests/cli/test_environment.py:15-18). - TRITON_PTXAS_PATH / CPATH unchanged: environment.py:75
if ptxas.is_file() and "TRITON_PTXAS_PATH" not in os.environ:== main:67; environment.py:77-81 == main:69-73. Retracted finding stands retracted. - Single decision point:
_DEFAULT_LINUX_CUDA = Path("/usr/local/cuda")(:22) + resolution :56-64. Only 10 added source lines. - System-level consequences: apply() runs synchronously once per process before torch import (serve.py:210/291/436/545, bench.py:205; torch imported at serve.py:219/444, bench.py:240). No threads, locks, caches, allocations, metrics, proto/core-format or Helios contract touched -> no contention/memory/failure-propagation findings; the metric/rate span check finds no rate, latency or admission metric changed by this PR.
- Caller interaction: serve.py:291
_prepareand serve.py:436 debug-serve call apply() afterHost.discover()andderive()— i.e. after planning but beforeimport torch, so an inherited toolkit now reaches torch/flashinfer/b12x as intended. - Tests run in CI: .github/workflows/python-cpu.yml:30-33 runs
.venv/bin/python -m pytest tests/ -qwith CUDA_VISIBLE_DEVICES:"" — the new suite executes; the_DEFAULT_LINUX_CUDAmonkeypatch keeps it host-independent. Author's "148 passed, 12/12" remains author-reported (CI status not observable here). - Fixture isolation: clean_environment tests/cli/test_environment.py:50-63 registers undo for absent keys via setenv-then-pop, so both present and absent variables are restored; stubs runtime_patches.apply (:52) so no real patch install.
- Contract/design: Principle 10 carve-out docs/design-review.md:89-92 permits documented CUDA dependency-setup env policies; docs/cli-design.md:46-62 reconciled, :1489 table row matches code, AGENTS.md:461-474 rewritten, docs/model-preparation.md:123-126 now defers to cli-design. Residual nit (already known): AGENTS.md:452-455 unqualified prohibition with no pointer to the :461 carve-out.
- No end-to-end evidence that the preserved CUDA_HOME actually steers flashinfer/nvcc; #636 carries no maintainer decision (dossier note 6/§4), PR triaged to plain triage:review. Tests assert the env dict only.
#4 [high] Research summary
Reviewed PR #690 at head 39796ea across correctness, system-level consequences, contracts and test/claim accuracy, reading environment.py at both heads, config.py, all four apply() call sites (serve.py:210/291/436/545, bench.py:205), kv_codec.py, tuning.py, the docs (cli-design.md, AGENTS.md, model-preparation.md), design-review.md principle 10, the new test suite and the CI workflow.
Two findings, both logged with citations and verbatim quotes in the scratchpad:
- Major (F1): a nonexistent/stale inherited
CUDA_HOMEis accepted on truthiness alone (environment.py:56-66, nois_dir()check unlike the/usr/local/cudabranch), so on a host that previously worked through/usr/local/cudaa leftover exportedCUDA_HOMEnow yields noTRITON_PTXAS_PATH/CPATHat all — strictly worse thanmain, and the new test test_environment.py:138-148 freezes that no-op as contract. It feedskv_codec._find_nvcc(kv_codec.py:21-38) with a bogus toolkit. Docs at cli-design.md:50-53/60-62 read as a validated fallback chain, which is not what the code does. - Minor (F2):
apply()is non-idempotent — :58 reads the sameos.environslot that :64/:66 writes, so a second call in one process can never re-reach the/usr/local/cudabranch. Latent today (one call per process) but a stale-state trap for any future re-use.
Everything else checks out: Windows, TRITON_PTXAS_PATH and CPATH handling are byte-identical to main; the change touches no hot path, lock, cache, allocation, metric, proto/core format or Helios contract (the rate/latency/admission span check finds nothing changed); the doc reconciliation and the principle-10 exception are genuine; and the new suite does run in PR CI (python-cpu.yml:30-33). Remaining gaps are the ones already carried in the dossier: no end-to-end evidence that preserving CUDA_HOME actually steers flashinfer/nvcc, and #636 still has no maintainer decision.
#5 [high] Verbatim doc + PR-text quotes (cli-design, AGENTS, model-preparation, principle 10)
Verbatim quotes for the report, read at pr/690 (head 39796ea):
docs/cli-design.md:46-57 (principle-10 carve-out text added by the PR):
"No environment-variable behavior switches. Flare reads environment variables only for CUDA device selection and non-Windows preparation toolkit dependency setup: CUDA_VISIBLE_DEVICES restricts which GPUs the caller exposed, which changes the GPU each index names, so Flare inspects it to interpret --gpus; on non-Windows hosts, when [paths] cuda is unset, ignition.cli.environment preserves a non-empty inherited CUDA_HOME before falling back to /usr/local/cuda (removing blank CUDA_HOME values when no toolkit source exists), and for any resolved toolkit it keeps a pre-set TRITON_PTXAS_PATH and prepends <toolkit>/include to CPATH when not already listed."
docs/cli-design.md:58-62:
"Two levels of precedence. ... Host CUDA toolkit discovery on non-Windows hosts falls back through inherited CUDA_HOME and /usr/local/cuda only when [paths] cuda is unset."
docs/cli-design.md:1489 (precedence table, CUDA toolkit row):
"| CUDA toolkit | [paths] cuda; otherwise on non-Windows hosts non-empty inherited CUDA_HOME, then /usr/local/cuda when present; otherwise native build libraries discover the system toolkit (on non-Windows hosts, a resolved toolkit also populates unset TRITON_PTXAS_PATH and prepends <toolkit>/include to CPATH) |"
AGENTS.md:461-472:
"- The only environment variables Flare inspects belong to its documented CUDA device selection and preparation dependency setup policies. ... on non-Windows hosts, it also preserves a non-empty inherited CUDA_HOME when [paths] cuda is unset (before falling back to /usr/local/cuda), keeps a pre-set TRITON_PTXAS_PATH, and preserves existing CPATH entries, as specified in the CLI design."
-> every doc statement says "preserves a non-empty inherited CUDA_HOME", i.e. presence of the variable, never validity of the directory. This is the wording that must be tightened if F1 (entry 1) is resolved as "document the no-existence-check policy" rather than "add is_dir()".
docs/model-preparation.md:123-126 (now defers instead of restating):
"[paths] cuda selects an explicit toolkit directory; when unset, non-Windows hosts follow the CUDA_HOME and /usr/local/cuda fallback rules in the CLI design before native build libraries discover the system toolkit."
Principle 10, docs/design-review.md:89-92: "10. Use explicit configuration. Settings belong in recipe declarations, configuration files, or CLI flags; explicit user values win over defaults. Environment-variable behavior switches are prohibited except for the documented CUDA device selection and dependency setup policies." -> the carve-out the PR relies on exists; the "explicit user values win over defaults" clause is what favours the PR's new precedence (inherited CUDA_HOME over /usr/local/cuda) and also what would favour /usr/local/cuda over a stale inherited value only if the inherited value were treated as a default — worth one sentence in the report as the tension F1 sits in.
PR-text accuracy check (section "What changed" / "Claimed result"):
- "TRITON_PTXAS_PATH ..., CPATH prepending, and Windows (os.name == "nt") behavior are unchanged" — TRUE by inspection (environment.py:67-81 identical to main:59-73).
- "Unset otherwise, removing any blank/whitespace CUDA_HOME from os.environ" — TRUE (:63-64).
- "Non-empty inherited CUDA_HOME from os.environ (whitespace stripped), preserved without falling back to /usr/local/cuda" — TRUE but the wording "without falling back" is the understatement: it is preserved without any existence check, which is the F1 defect; the PR text never states that a nonexistent CUDA_HOME disables toolkit env.
- Tests: 8 functions, 12 parametrized cases (tests/cli/test_environment.py:66,81,96,109,122,138 + 3+3 at :151,:165) — author's "12/12" is accurate.
File counts from the header (pr_diff broken at this head: "Could not read c513e46a..."): AGENTS.md +13/-8, docs/cli-design.md +18/-9, docs/model-preparation.md +4/-3, ignition/cli/environment.py +10/-2, tests/cli/test_environment.py +175/-0.
#6 [high] Findings ranking, area verdicts, and tooling caveat
Ranking and disposition guidance for the final report (2 findings total; area verdicts):
- F1 — Major. Stale/nonexistent inherited CUDA_HOME silently disables toolkit environment. Evidence: ignition/cli/environment.py:56-66 (no
is_dir()on the inherited branch, unlike :61) + tests/cli/test_environment.py:138-148 (freezes it) + docs/cli-design.md:50-53, :1489, AGENTS.md:470 (do not disclose no-existence-check). Concrete fix:if inherited_cuda and Path(inherited_cuda).is_dir():(keeping :61-64 unchanged so the /usr/local/cuda fallback and the pop still apply), or keep behaviour and document "used verbatim, no existence check" and rewrite the test's name/assertion accordingly. Reviewer should pick one; not merge-blocking on its own but the PR is a regression fix, and this adds a fresh regression for the stale-env population. - F2 — Minor. apply() non-idempotent (:58 reads the slot :64/:66 writes). Latent; note it as a forward hazard, not a defect of this PR's single-call paths.
Areas clean — state plainly, do not invent issues:
- Correctness of the intended path: precedence order, whitespace strip, blank-value pop, and the
[paths] cudaoverride all match the PR text and the tests. - Platform parity: Windows untouched (environment.py:67-72 == main:59-64); the new branch is correctly gated by
os.name != "nt". Windows remains untested (both before and after this PR). - System-level: no concurrency, lock, queue, buffering, allocation, I/O or metric change; apply() is a synchronous once-per-process pre-import step (torch imported later at serve.py:219/444, bench.py:240). Metric/rate/admission span check: N/A — no metric is sampled by this PR.
- Contracts: no wire/proto/captured-graph/public contract change; docs reconciled; principle-10 carve-out genuinely documented (design-review.md:89-92).
- Tests: new suite is host-independent (monkeypatched _DEFAULT_LINUX_CUDA) and does execute in PR CI (.github/workflows/python-cpu.yml:30-33 with CUDA_VISIBLE_DEVICES:""); fixture restores both present and absent keys (test_environment.py:50-63).
- Residual (carry from dossier, not re-derived): AGENTS.md:452-455 unqualified prohibition lacks a pointer to the :461 carve-out; no end-to-end evidence that the preserved CUDA_HOME steers flashinfer/nvcc (#231's review ask); #636 still has no maintainer decision while the PR is triaged
triage:review.
Tooling caveat to repeat: pr_diff and search_history both fail at this head ("Could not read c513e46a…"), so the diff was reconstructed by reading files at pr/690 and main.
#2 [medium] F2 Minor: apply() is non-idempotent — it reads its own output as "inherited" CUDA_HOME
ignition/cli/environment.py:58 reads os.environ.get("CUDA_HOME") at the same time :64/:66 writes it. So the input to the precedence decision is the same mutable process dict the function mutates. If apply() runs twice in one process (only one call per process path today: serve.py:210, 291, 436, 545; bench.py:205 — all single-shot per CLI command), the second call can never reach the _DEFAULT_LINUX_CUDA branch: a fallback written at :66 makes the next call see it as an inherited (pre-existing) value, and a popped value at :64 makes the next call see "no inherited CUDA_HOME" even though the caller originally exported a blank one. Result differs from the first call (first call w/ no env + no /usr/local/cuda -> CUDA_HOME unset; but a second call after a first call that set /usr/local/cuda keeps /usr/local/cuda).
Impact today: latent only (no second call site); becomes a real stale-state bug the moment apply() is invoked per-test, per-export-step, or in a long-lived supervisor that re-reads config (e.g. a future re-prepare or a config reload). Also means the new suite cannot detect ordering mistakes — every test builds a fresh config but relies on the fixture to reset os.environ.
Fix: capture the inherited value once (_INHERITED_CUDA_HOME = os.environ.get("CUDA_HOME") at module import, or pass it into apply as an argument) and treat the mutation of os.environ as output only.