commit 1c7566e06a2e4ca91aaae22c312319eae51a73a0
parent 7ee211f6aec4dd5496fc00c518abeacbee3fa6d7
Author: triesap <tyson@radroots.org>
Date: Mon, 15 Jun 2026 14:04:15 -0700
provider: bound control health probes
- cap sys.status and sys.capabilities provider health checks at 500ms
- keep business request timeout handling separate from control-route diagnostics
- cover timeout classification through status and capabilities stdio routes
Diffstat:
2 files changed, 111 insertions(+), 2 deletions(-)
diff --git a/src/hyf_stdio/control/assisted_runtime.mojo b/src/hyf_stdio/control/assisted_runtime.mojo
@@ -13,10 +13,22 @@ from hyf_runtime.config import (
assisted_runtime_configured,
assisted_execution_enabled,
)
-from hyf_provider.config import max_local_provider_config_from_runtime
+from hyf_provider.config import (
+ MaxLocalProviderConfig,
+ max_local_provider_config_from_runtime,
+)
from hyf_provider.max_local import max_local_provider_status
+def _control_route_provider_config(
+ config: MaxLocalProviderConfig,
+) -> MaxLocalProviderConfig:
+ var capped = config.copy()
+ if capped.request_timeout_ms > 500:
+ capped.request_timeout_ms = 500
+ return capped^
+
+
def _base_status(
configured: Bool,
transport: String,
@@ -95,7 +107,9 @@ def resolve_assisted_runtime_status(
try:
var provider_config = max_local_provider_config_from_runtime(config)
- var status = max_local_provider_status(provider_config)
+ var status = max_local_provider_status(
+ _control_route_provider_config(provider_config)
+ )
return _base_status(
configured=True,
transport="http",
diff --git a/tests/test_stdio_contract.mojo b/tests/test_stdio_contract.mojo
@@ -875,6 +875,49 @@ def test_status_reports_ready_max_local_provider_truthfully() raises:
provider_stub.wait()
+def test_status_bounds_max_local_health_probe_timeout() raises:
+ with TemporaryDirectory() as temp_dir:
+ var provider_port = reserve_loopback_port()
+ var provider_stub = spawn_max_local_stub(
+ provider_port, "health_timeout", 1
+ )
+ var startup_config_path = Path(temp_dir) / "explicit-hyf-config.toml"
+ startup_config_path.write_text(
+ _max_local_runtime_config_toml_with_urls(
+ "http://127.0.0.1:" + String(provider_port) + "/v1",
+ "http://127.0.0.1:" + String(provider_port) + "/health",
+ 15000,
+ )
+ )
+ with ScopedEnvVar(HYF_PATHS_PROFILE_ENV, "repo_local"):
+ with ScopedEnvVar(HYF_PATHS_REPO_LOCAL_ROOT_ENV, temp_dir):
+ var response = run_stdio_entrypoint(
+ "src/main.mojo",
+ load_scenario_request_json("scenarios/status_ok.json"),
+ "--config",
+ startup_config_path.__fspath__(),
+ )
+
+ assert_true(response["ok"].bool_value())
+ assert_equal(
+ response["output"]["assisted_runtime"]["state"]
+ .string_value(),
+ "unavailable",
+ )
+ assert_equal(
+ response["output"]["assisted_runtime"]["reason"]
+ .string_value(),
+ "timeout",
+ )
+ assert_equal(
+ response["output"]["assisted_runtime"]["reachable"]
+ .bool_value(),
+ False,
+ )
+
+ provider_stub.wait()
+
+
def test_status_rejects_invalid_max_local_runtime_config() raises:
var prefix = (
'[service]\ntransport = "stdio"\n\n'
@@ -1081,6 +1124,58 @@ def test_capabilities_reports_ready_max_local_provider_truthfully() raises:
provider_stub.wait()
+def test_capabilities_bounds_max_local_health_probe_timeout() raises:
+ with TemporaryDirectory() as temp_dir:
+ var provider_port = reserve_loopback_port()
+ var provider_stub = spawn_max_local_stub(
+ provider_port, "health_timeout", 1
+ )
+ var startup_config_path = Path(temp_dir) / "explicit-hyf-config.toml"
+ startup_config_path.write_text(
+ _max_local_runtime_config_toml_with_urls(
+ "http://127.0.0.1:" + String(provider_port) + "/v1",
+ "http://127.0.0.1:" + String(provider_port) + "/health",
+ 15000,
+ )
+ )
+ with ScopedEnvVar(HYF_PATHS_PROFILE_ENV, "repo_local"):
+ with ScopedEnvVar(HYF_PATHS_REPO_LOCAL_ROOT_ENV, temp_dir):
+ var response = run_stdio_entrypoint(
+ "src/main.mojo",
+ load_scenario_request_json("scenarios/capabilities_ok.json"),
+ "--config",
+ startup_config_path.__fspath__(),
+ )
+
+ assert_true(response["ok"].bool_value())
+ assert_equal(
+ response["output"]["business_capabilities"][0][
+ "assisted_execution"
+ ].string_value(),
+ "unavailable",
+ )
+ assert_equal(
+ response["output"]["business_capabilities"][0][
+ "assisted_backend_available"
+ ].bool_value(),
+ False,
+ )
+ assert_equal(
+ response["output"]["assisted_runtime_capabilities"][0][
+ "state"
+ ].string_value(),
+ "unavailable",
+ )
+ assert_equal(
+ response["output"]["assisted_runtime_capabilities"][0][
+ "reason"
+ ].string_value(),
+ "timeout",
+ )
+
+ provider_stub.wait()
+
+
def test_query_rewrite_falls_back_deterministically_when_provider_is_unavailable() raises:
with TemporaryDirectory() as temp_dir:
var startup_config_path = Path(temp_dir) / "explicit-hyf-config.toml"