Implements Phase 1 of the runtime model-adapter registry with capability/format negotiation as described in issue #333. This feature adds the missing runtime glue between the backend abstraction, model orchestration, and hardware discovery layers, enabling pluggable inference backends to be discovered, loaded, and managed dynamically at runtime.
- Closes #333
Without an adapter registry + negotiation layer, MoFA risks:
- Hardcoded backend routing
- Fragile model loading across formats/modalities
- Poor extensibility for new model families
- Inconsistent behavior across hardware backends
This implementation provides a clean abstraction for runtime adapter discovery, addressing the key unresolved questions from ideas/mofa-agents/call-for-proposal.md:
- "How do model adapters get discovered, loaded, and managed at runtime?"
- "How does MoFA handle model format differences (safetensors, GGUF, checkpoints)?"
- New module:
crates/mofa-foundation/src/adapter/with 6 new files - AdapterDescriptor: Describes adapter capabilities (modalities, formats, quantization, hardware)
- AdapterRegistry: Runtime registration, discovery, and deterministic resolution
- ModelConfig & HardwareProfile: Configuration types for model selection
- Error types: Structured rejection reasons with severity levels (Hard/Soft)
- Resolver: Phase 2-ready weighted scoring with EWMA runtime stats
- Unit tests pass:
cargo test -p mofa-foundation - Adapter resolution tested:
- No-compatible-adapter case returns proper error
- Multi-candidate deterministic selection (priority → alphabetical)
- Format mismatch rejection
- Modality mismatch rejection
- Code quality:
cargo fmtandcargo clippypass
# Run tests
cargo test -p mofa-foundation -- adapter
# Check formatting
cargo fmt --all
# Lint
cargo clippy -p mofa-foundation -- -D warnings- No breaking changes
- Code follows Rust idioms and project conventions
-
cargo fmtrun -
cargo clippypasses without warnings - Tests added/updated (included in each module)
- Public APIs documented with doc comments
- PR is small and focused (one logical change)
- Branch is up to date with
main
No special deployment requirements. This is a pure library addition to mofa-foundation.
- Implements both Phase 1 (core registry) and Phase 2 (weighted scoring) components
- Designed to integrate with existing work: #296 (InferenceBackend trait), #147 (Core Trait for Model Orchestration), #221 (Hardware Discovery Service)
- Includes builder patterns for all public types for ergonomic API usage