Skip to content

Feat: Refactor error handling and enhance server capabilities#1

Merged
BH3GEI merged 5 commits into
mainfrom
engine
Jun 29, 2026
Merged

Feat: Refactor error handling and enhance server capabilities#1
BH3GEI merged 5 commits into
mainfrom
engine

Conversation

@aayank13

Copy link
Copy Markdown
Collaborator
  • Introduced structured error handling with ErrorInfo and ErrorCode enums in mofa-kernel.
  • Updated EngineError to provide machine-readable error codes and retryable status.
  • Enhanced the server API by adding a new endpoint for resource refresh.
  • Simplified error responses in the server by utilizing the new ErrorInfo structure.
  • Improved model provider traits to include methods for loading and unloading models.
  • Added backend health and feature reporting to enhance observability.
  • Updated model status logic to derive from richer state information.
  • Refactored model card structure to include execution state and availability.

- Introduced structured error handling with ErrorInfo and ErrorCode enums in mofa-kernel.
- Updated EngineError to provide machine-readable error codes and retryable status.
- Enhanced the server API by adding a new endpoint for resource refresh.
- Simplified error responses in the server by utilizing the new ErrorInfo structure.
- Improved model provider traits to include methods for loading and unloading models.
- Added backend health and feature reporting to enhance observability.
- Updated model status logic to derive from richer state information.
- Refactored model card structure to include execution state and availability.
@aayank13 aayank13 requested a review from BH3GEI June 21, 2026 15:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the engine/kernel contracts to provide structured, machine-readable error handling and richer backend/model state, while expanding server and provider capabilities to support discovery/health reporting and manual refresh.

Changes:

  • Introduces ErrorCode/ErrorInfo and updates EngineError to expose stable codes, retryability, and optional source provider.
  • Expands model/runtime state (health, availability, residency, execution) and updates routing + status derivation accordingly.
  • Enhances the HTTP API with /v1/discovery/refresh, richer status reporting, and standardized error responses.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
mofa-kernel/src/types.rs Adds backend/model state types, canonical model ID helpers, fallback policy, and richer request/response fields.
mofa-kernel/src/traits.rs Extends provider trait with name/kind/features plus typed discover/health/load/unload.
mofa-kernel/src/lib.rs Re-exports new error types (ErrorCode, ErrorInfo).
mofa-kernel/src/error.rs Implements structured error info + stable error codes and retryability.
mofa-engine-sdk/src/server.rs Standardizes error responses to ErrorInfo and adds /v1/discovery/refresh.
mofa-engine-sdk/src/lib.rs Reorders module declarations (no functional change).
mofa-engine-core/src/router.rs Refactors routing to use provider health/circuit state and richer model state; adds explainable decisions.
mofa-engine-core/src/memory.rs Minor formatting-only refactor.
mofa-engine-core/src/lib.rs Reorders module declarations/exports.
mofa-engine-core/src/engine.rs Adds validated engine construction, refresh flow, health tracking, lifecycle loading, fallback policy, and richer events/status.
mofa-engine-core/src/config.rs Adds checked config loading + validation; defaults host to 127.0.0.1.
mofa-engine-core/src/circuit_breaker.rs Minor formatting-only refactor.
mofa-engine-core/src/backends/openai_compat.rs Updates OpenAI-compatible backend to new Provider contract + lifecycle no-ops + capability checks.
mofa-engine-core/src/backends/ollama.rs Updates Ollama backend to new Provider contract + discovery/health + load/unload hooks and residency inspection.
mofa-engine-core/src/backends.rs New module file exporting provider backend implementations.
mofa-engine-app/src/main.rs Switches production startup to checked config + Engine::try_new.
docs/openapi.yaml Adds OpenAPI spec documenting refresh endpoint and structured errors.
docs/decisions/0001-stage-0-2-baseline.md Adds ADR capturing baseline decisions (IDs, fallback, health/residency split, bind address).
docs/acceptance.md Adds acceptance checklist tracking for stage 0–2 baseline.
.github/workflows/ci.yml Adds Rust CI workflow (fmt/clippy/test).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mofa-engine-core/src/router.rs Outdated
Comment thread mofa-engine-core/src/router.rs
Comment thread mofa-engine-core/src/router.rs
Comment thread mofa-kernel/src/types.rs
Comment thread mofa-engine-core/src/engine.rs Outdated
…dd compatibility for legacy naming conventions

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.

Comment thread mofa-engine-core/src/engine.rs Outdated
Comment thread mofa-engine-core/src/engine.rs Outdated
Comment thread mofa-engine-core/src/engine.rs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.

Comment thread mofa-engine-core/src/engine.rs
Comment thread mofa-engine-core/src/engine.rs
Comment thread docs/openapi.yaml Outdated
@BH3GEI BH3GEI merged commit 62ecce3 into main Jun 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants