Repository navigation
fix: retry provider discovery periodically instead of once at startup - #19
Open
AditiSah05 wants to merge 1 commit into
Open
AditiSah05 wants to merge 1 commit into
AditiSah05 wants to merge 1 commit into
Conversation
AditiSah05
force-pushed
the
feat/discovery-retry-ticker
branch
from
September 2, 2026 18:41
7794440 to
448ddf6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Provider discovery (
discover_all()) ran exactly once, at engine startup (engine.rs, in the constructor). If a provider — e.g. Ollama — wasn't reachable at that exact moment, the engine marked it unavailable and never checked again.Consequence: start Ollama after the engine (slow boot, forgot to start it, container startup-order race), and
/v1/capabilitiesstays empty forever. The only way out is a manualPOST /v1/discovery/refreshcall or a full engine restart — neither is discoverable to a normal user, and both contradict the project's own "zero-config, auto-detects, auto-recovers" pitch in the README.The engine already runs two other background loops that repeat forever —
spawn_idle_eviction()(unloads idle models) andspawn_artifact_sweep()(cleans old files). Discovery had no equivalent.Fix
mofa-engine-core/src/engine.rsspawn_discovery_ticker()— same pattern as the two existing tickers: atokio::spawnloop on atokio::time::interval, callingrefresh_resources()(discovery + health) every tick.discovery_task(task handle) anddiscovery_interval; both cleaned up inDrop(task aborted on engine shutdown, matching existing tasks).discovery_ticker_picks_up_a_provider_that_was_down_at_startup: a fake provider (FlakyDiscoveryProvider) fails discovery until flipped "available" mid-test; the test asserts the model appears incapabilities()on its own, with no manualrefresh_resources()call after the initial startup check.build_engine_with_pricingtest helper gained adiscovery_secsparameter (3 call sites updated); a few explicitEngineConfig { ... }test literals needed the new field.mofa-engine-core/src/config.rsDiscoveryConfigstruct:refresh_secs: u64, default30,0disables the background refresh (same "0 = off" convention asidle_timeout_secsandartifacts.retention_secs).EngineConfigas a newdiscoveryfield.mofa-engine-sdk/src/client.rs,mofa-engine-sdk/src/server.rsEngineConfig { ... }literals updated to include the new field so the crates still compile.config.example.toml[discovery]section documentingrefresh_secs.Testing
cargo test -p mofa-engine-core— 179 passed. (9 pre-existing failures are unrelated to this change: local TTS/ASR/image-gen fixture tests spawnsh, which isn't on PATH on this Windows dev machine.)cargo test -p mofa-engine-sdk— 17 passed, including the existingauth_gate_rejects_missing_token_but_allows_public_routestest (unaffected).cargo build --workspace— clean.Live-verified end to end, not just unit-tested:
refresh_secs(5s in this run), not a single one-shot warning as before.discovered 1 models from 'ollama'and/v1/capabilitiesreturned the model — confirmed in the dashboard UI too.Non-goals
/v1/capabilities; this PR just makes the data behind that endpoint stay fresh.POST /v1/discovery/refreshendpoint — still works, still useful for an immediate on-demand check.