Perform agent connectivity test on startup#228
Open
zeroklaw wants to merge 7 commits into
Open
Conversation
Add `check_agent_health` async function to `src/harness.rs` that queries the `/health` endpoint of each configured agent and verifies the response contains `status: "ok"`. Integrate this into `src/main.rs` as a startup check after trigger validation and before the server starts. New types: - `HealthResponse`: deserializes the `/health` JSON response - `HealthCheckError`: typed errors for HTTP failures, bad status codes, and parse failures The startup health check iterates over `config.agents` and fails fast if any agent is unreachable or reports an unhealthy status, preventing the server from starting with broken agent connectivity. Tests added: - `tests/harness_tests.rs`: 7 new health check tests (all_healthy, bad_status, http_error, parse_error, unhealthy_status, trailing_slash) - `tests/health_startup_tests.rs`: 6 new integration tests covering multi-agent scenarios, connection refused, invalid JSON, and URL construction - `src/harness.rs` inline tests: 3 Display tests for HealthCheckError variants Docs updated: - `README.md`: documented the startup agent health check behavior - `AGENTS.md`: documented the new health check types and startup flow
Fix compilation error in src/harness.rs (missing semicolon after format!() call) and fix mockito API usage in test files (ServerGuard::new_async() -> Server::new_async()). Closes #224
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.
Summary
Implements agent connectivity health check on startup as requested in #224.
On startup, Yoke now queries the
/healthendpoint of each configured agent before starting the server. If any agent is unreachable, returns a non-200 status code, or reports a status other thanok, Yoke reports an error and exits without starting the server.Changes
src/harness.rsHealthResponsestruct (status,platform,version:String, derivesDebug,Clone,Deserialize)HealthCheckErrorenum withHttp,BadStatus, andParsevariants (usesthiserror)check_agent_healthasync function that queries{base_url}/healthand verifiesstatus == "ok"Displaytests forHealthCheckErrorvariantssrc/main.rsuse yoke::harness::check_agent_health;importvalidate_triggersblock, beforewatch::channel(false)info!level with agent name, platform, and versionContextErrorwrappingHealthCheckErroron any agent failuretests/harness_tests.rsall_healthy,bad_status,http_error,parse_error,unhealthy_status,trailing_slashtests/health_startup_tests.rs(new file)multi_agent_all_healthy,multi_agent_one_unhealthy,multi_agent_status_not_ok,multi_agent_invalid_json,multi_agent_connection_refused,health_check_url_constructionREADME.mdAGENTS.mdCloses #224