advisor: enforce manifest-authoritative runtime adapter loading#51
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5913ca2958
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| adapter_model_path = Path(str(artifact_paths["adapter_model"])).expanduser() | ||
| if not adapter_model_path.is_absolute(): | ||
| adapter_model_path = Path(checkpoint_metadata["checkpoint_path"]) / adapter_model_path | ||
| if not adapter_model_path.exists(): |
There was a problem hiding this comment.
Validate adapter_model as a file path
In resolve_manifest_adapter_artifact, existence is treated as sufficient validation, so malformed manifests like "adapter_model": "" (or a directory path) are accepted because the resolved checkpoint directory exists. I traced this through _ensure_loaded: the returned directory path becomes adapter_artifact_path, then adapter_dir is computed as its parent, and mlx_lm_load is called with the wrong adapter directory. This can cause active checkpoints to fail loading or load from an unintended location instead of failing fast; requiring a non-empty file path (e.g., is_file()) would prevent this.
Useful? React with 👍 / 👎.
checkpoint.jsonmanifestartifact_paths.adapter_modelas the source of truth.adapter_modelis present.Testing
pytest tests/agent/advisor/test_runtime_mlx.py -k 'manifest_adapter_artifact or active_checkpoint_without_real_adapter or active_profile_adapter_metadata or loads_active_profile_adapter' -qpytest tests/agent/advisor/test_runtime_mlx.py -qpytest tests/agent/advisor/test_training_runtime.py tests/agent/advisor/test_operator_runtime.py -qruff check .python -m pytest tests/agent/advisor -q