fix(miles-pipeline): narrow startup-validation import guard to ModuleNotFoundError - #32
Conversation
…NotFoundError The F10 topology validation import was wrapped in `except Exception`, which skipped all validation on any import error and defeated the fail-fast intent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
JunzheJoe
left a comment
There was a problem hiding this comment.
This is the right boundary for the F10 guard. except Exception swallowed every failure mode of the validation import — including a syntactically-broken or partially-installed miles — turning the whole C-check chain into best-effort. ModuleNotFoundError keeps exactly the legitimate skip (miles absent in test/dev fixtures, which is how the repo's own tests run) while a name-level failure (from ... import assert_rlix_topology with the module present) raises plain ImportError and now fails fast, as does any SyntaxError.
One boundary case worth knowing (fine as-is): a missing transitive dep inside rlix_validation's import chain also surfaces as ModuleNotFoundError and takes the skip path — that's the partial-dev-env case and matches the documented test-fixture intent. In production miles + deps are installed, so the guard only ever skips when miles genuinely isn't there. Closes the F10-FAILOPEN review finding. LGTM.
Context
MilesPipeline._validate_topology()runs the F10 startup topology validation before any GPU allocation, so a misconfigured run fails fast with a clear message instead of OOM-ing mid-init.It imports the validator lazily and wraps the import in a guard so a machine without
milesinstalled (test/dev fixtures) can still construct the pipeline:Problem
except Exceptionis too broad. It catches any failure while importing the validator — not just "miles not installed" (ModuleNotFoundError), but alsoSyntaxError,AttributeError, or a broken transitive import insiderlix_validationitself (ImportError). In all those cases the code logs a warning and silently skips every C1–C23 check, which defeats the whole point of the fail-fast guard: a real bug in the validator would let a misconfigured topology through to a mid-init OOM.In production
milesis always importable, so the only legitimate skip reason isModuleNotFoundError(package genuinely absent). Anything else is a real bug and should propagate. This also matches the existing narrow pattern incoordinator.py(except ModuleNotFoundErroron dynamicpipeline_clsimport).Change
except Exceptiontoexcept ModuleNotFoundError.# noqa: BLE001(no longer a blind except).ImportError/SyntaxErrornow propagate and fail fast; themiles_args is Nonetest-fixture path (a few lines up) is unaffected.🤖 Generated with Claude Code