hyf

Context-aware query service for Radroots
git clone https://radroots.dev/git/hyf.git
Log | Files | Refs | README | LICENSE

commit e13907c7ae4aac5ad3d5ecdb19b82f38ff092528
parent 723d29ccbf1062cc40d39d9b865e0dcd2c327aa3
Author: triesap <tyson@radroots.org>
Date:   Thu, 18 Jun 2026 13:24:14 -0700

provider: derive max local route

- remove max local route from runtime config

- reject stale route config fields

- report provider route from the assisted contract

Diffstat:
Msrc/hyf_assist/contract.mojo | 4++++
Msrc/hyf_provider/config.mojo | 2--
Msrc/hyf_provider/health.mojo | 3++-
Msrc/hyf_provider/max_local.mojo | 3++-
Msrc/hyf_runtime/config.mojo | 31++++++++++++++++++++++++-------
Msrc/hyf_runtime/status.mojo | 3++-
Mtests/test_provider_adapter.mojo | 11++++++++---
Mtests/test_stdio_contract.mojo | 22+---------------------
8 files changed, 43 insertions(+), 36 deletions(-)

diff --git a/src/hyf_assist/contract.mojo b/src/hyf_assist/contract.mojo @@ -9,6 +9,10 @@ def provider_runtime_id() -> String: return "hyf_provider_runtime" +def max_local_query_rewrite_route() -> String: + return "provider_runtime.query_rewrite.max_local" + + def assisted_runtime_supported_business_capabilities() -> List[String]: var capabilities = List[String]() capabilities.append("query_rewrite") diff --git a/src/hyf_provider/config.mojo b/src/hyf_provider/config.mojo @@ -9,7 +9,6 @@ struct MaxLocalProviderConfig(Copyable, Movable): var base_url: String var health_url: String var model: String - var route: String var request_timeout_ms: Int @@ -24,6 +23,5 @@ def max_local_provider_config_from_runtime( base_url=String(source.base_url), health_url=String(source.health_url), model=String(source.model), - route=String(source.route), request_timeout_ms=source.request_timeout_ms, ) diff --git a/src/hyf_provider/health.mojo b/src/hyf_provider/health.mojo @@ -1,3 +1,4 @@ +from hyf_assist.contract import max_local_query_rewrite_route from hyf_provider.client import make_max_local_http_client from hyf_provider.config import MaxLocalProviderConfig from hyf_provider.result import MaxLocalProviderStatus @@ -12,7 +13,7 @@ def _provider_status( return MaxLocalProviderStatus( backend_kind="max_local", provider="max_local", - route=String(config.route), + route=max_local_query_rewrite_route(), model=String(config.model), reachable=reachable, state=String(state), diff --git a/src/hyf_provider/max_local.mojo b/src/hyf_provider/max_local.mojo @@ -1,5 +1,6 @@ from std.time import perf_counter_ns +from hyf_assist.contract import max_local_query_rewrite_route from hyf_core.capabilities.query_analysis import QueryAnalysis from hyf_core.request_context import RequestContext from hyf_provider.client import ( @@ -48,7 +49,7 @@ def execute_query_rewrite_via_max_local_provider( response.json() ), provider="max_local", - route=String(config.route), + route=max_local_query_rewrite_route(), model=String(config.model), latency_ms=latency_ms, schema_version=query_rewrite_schema_version(), diff --git a/src/hyf_runtime/config.mojo b/src/hyf_runtime/config.mojo @@ -28,7 +28,6 @@ struct HyfMaxLocalProviderRuntimeConfig(Defaultable, Copyable, Movable): var base_url: String var health_url: String var model: String - var route: String var request_timeout_ms: Int def __init__(out self): @@ -36,7 +35,6 @@ struct HyfMaxLocalProviderRuntimeConfig(Defaultable, Copyable, Movable): self.base_url = "" self.health_url = "" self.model = "" - self.route = "" self.request_timeout_ms = 0 @@ -109,7 +107,9 @@ def load_runtime_config(path: String) -> HyfLoadedRuntimeConfig: return default_loaded_runtime_config() try: - var config = from_toml[HyfRuntimeConfig](Path(path).read_text()) + var config_text = Path(path).read_text() + _reject_removed_max_local_route_config(config_text) + var config = from_toml[HyfRuntimeConfig](config_text) _validate_runtime_config(config) return HyfLoadedRuntimeConfig( artifact_present=True, @@ -180,6 +180,27 @@ def _require_http_url(value: String, context: String) raises: raise Error(context + " must use http or https") +def _reject_removed_max_local_route_config(config_text: String) raises: + var in_max_local = False + for raw_line in config_text.splitlines(): + var line = String(raw_line).strip() + if line == "" or line.startswith("#"): + continue + if line.startswith("["): + in_max_local = line == "[assisted.max_local]" + continue + if not in_max_local: + continue + var equals_index = line.find("=") + if equals_index < 0: + continue + var key = String(line[byte=0:equals_index]).strip() + if key == "route": + raise Error( + "assisted.max_local.route has been removed; provider route is derived by HYF" + ) + + def _validate_max_local_provider_config( config: HyfMaxLocalProviderRuntimeConfig ) raises: @@ -197,9 +218,5 @@ def _validate_max_local_provider_config( _require_no_boundary_whitespace( config.model, "assisted.max_local.model" ) - _require_non_empty(config.route, "assisted.max_local.route") - _require_no_boundary_whitespace( - config.route, "assisted.max_local.route" - ) if config.request_timeout_ms <= 0: raise Error("assisted.max_local.request_timeout_ms must be greater than zero") diff --git a/src/hyf_runtime/status.mojo b/src/hyf_runtime/status.mojo @@ -1,5 +1,6 @@ from json import Value, loads +from hyf_assist.contract import max_local_query_rewrite_route from hyf_runtime.config import assisted_runtime_configured from hyf_runtime.diagnostics import ( diagnostics_debug_override_dir_from_env, @@ -96,7 +97,7 @@ def build_runtime_status_value(context: RuntimeStartupContext) raises -> Value: ) effective.set( "max_local_route", - Value(String(context.config.effective.assisted.max_local.route)), + Value(max_local_query_rewrite_route()), ) effective.set( "max_local_request_timeout_ms", diff --git a/tests/test_provider_adapter.mojo b/tests/test_provider_adapter.mojo @@ -2,6 +2,7 @@ from std.testing import TestSuite, assert_equal, assert_raises, assert_true from json import Value, loads +from hyf_assist.contract import max_local_query_rewrite_route from hyf_core.request_context import default_request_context from hyf_provider.client import max_local_chat_completions_url from hyf_provider.config import ( @@ -41,7 +42,6 @@ def _provider_runtime_config() -> HyfLoadedRuntimeConfig: base_url="http://127.0.0.1:8000/v1/", health_url="http://127.0.0.1:8000/health", model="max-local-query-rewrite", - route="provider_runtime.query_rewrite.max_local", request_timeout_ms=15000, ), ), @@ -54,7 +54,6 @@ def _provider_config() -> MaxLocalProviderConfig: base_url="http://127.0.0.1:8000/v1/", health_url="http://127.0.0.1:8000/health", model="max-local-query-rewrite", - route="provider_runtime.query_rewrite.max_local", request_timeout_ms=15000, ) @@ -95,10 +94,16 @@ def test_provider_config_maps_runtime_config() raises: assert_equal(config.base_url, "http://127.0.0.1:8000/v1/") assert_equal(config.health_url, "http://127.0.0.1:8000/health") assert_equal(config.model, "max-local-query-rewrite") - assert_equal(config.route, "provider_runtime.query_rewrite.max_local") assert_equal(config.request_timeout_ms, 15000) +def test_max_local_route_is_derived_from_assisted_contract() raises: + assert_equal( + max_local_query_rewrite_route(), + "provider_runtime.query_rewrite.max_local", + ) + + def test_provider_config_rejects_unconfigured_runtime() raises: with assert_raises(): _ = max_local_provider_config_from_runtime( diff --git a/tests/test_stdio_contract.mojo b/tests/test_stdio_contract.mojo @@ -58,7 +58,6 @@ def _max_local_runtime_config_toml_with_urls( + health_url + '"\n' + 'model = "max-local-query-rewrite"\n' - + 'route = "provider_runtime.query_rewrite.max_local"\n' + 'request_timeout_ms = ' + String(request_timeout_ms) + "\n" @@ -944,7 +943,6 @@ def test_status_rejects_invalid_max_local_runtime_config() raises: + 'base_url = "http://127.0.0.1:8000/v1"\n' + 'health_url = "http://127.0.0.1:8000/health"\n' + 'model = "max-local-query-rewrite"\n' - + 'route = "provider_runtime.query_rewrite.max_local"\n' + 'request_timeout_ms = 15000\n', "runtime.allow_assisted", ) @@ -954,7 +952,6 @@ def test_status_rejects_invalid_max_local_runtime_config() raises: + max_local_header + 'health_url = "http://127.0.0.1:8000/health"\n' + 'model = "max-local-query-rewrite"\n' - + 'route = "provider_runtime.query_rewrite.max_local"\n' + 'request_timeout_ms = 15000\n', "assisted.max_local.base_url", ) @@ -965,7 +962,6 @@ def test_status_rejects_invalid_max_local_runtime_config() raises: + 'base_url = " http://127.0.0.1:8000/v1"\n' + 'health_url = "http://127.0.0.1:8000/health"\n' + 'model = "max-local-query-rewrite"\n' - + 'route = "provider_runtime.query_rewrite.max_local"\n' + 'request_timeout_ms = 15000\n', "assisted.max_local.base_url", ) @@ -976,7 +972,6 @@ def test_status_rejects_invalid_max_local_runtime_config() raises: + 'base_url = "http://127.0.0.1:8000/v1"\n' + 'health_url = "http://127.0.0.1:8000/health "\n' + 'model = "max-local-query-rewrite"\n' - + 'route = "provider_runtime.query_rewrite.max_local"\n' + 'request_timeout_ms = 15000\n', "assisted.max_local.health_url", ) @@ -987,7 +982,6 @@ def test_status_rejects_invalid_max_local_runtime_config() raises: + 'base_url = "file:///tmp/max"\n' + 'health_url = "http://127.0.0.1:8000/health"\n' + 'model = "max-local-query-rewrite"\n' - + 'route = "provider_runtime.query_rewrite.max_local"\n' + 'request_timeout_ms = 15000\n', "assisted.max_local.base_url", ) @@ -998,7 +992,6 @@ def test_status_rejects_invalid_max_local_runtime_config() raises: + 'base_url = "http://127.0.0.1:8000/v1"\n' + 'health_url = "http://127.0.0.1:8000/health"\n' + 'model = " max-local-query-rewrite"\n' - + 'route = "provider_runtime.query_rewrite.max_local"\n' + 'request_timeout_ms = 15000\n', "assisted.max_local.model", ) @@ -1009,7 +1002,6 @@ def test_status_rejects_invalid_max_local_runtime_config() raises: + 'base_url = "http://127.0.0.1:8000/v1"\n' + 'health_url = "http://127.0.0.1:8000/health"\n' + 'model = ""\n' - + 'route = "provider_runtime.query_rewrite.max_local"\n' + 'request_timeout_ms = 15000\n', "assisted.max_local.model", ) @@ -1020,18 +1012,7 @@ def test_status_rejects_invalid_max_local_runtime_config() raises: + 'base_url = "http://127.0.0.1:8000/v1"\n' + 'health_url = "http://127.0.0.1:8000/health"\n' + 'model = "max-local-query-rewrite"\n' - + 'route = "provider_runtime.query_rewrite.max_local "\n' - + 'request_timeout_ms = 15000\n', - "assisted.max_local.route", - ) - _assert_invalid_runtime_config_load_error( - prefix - + provider - + max_local_header - + 'base_url = "http://127.0.0.1:8000/v1"\n' - + 'health_url = "http://127.0.0.1:8000/health"\n' - + 'model = "max-local-query-rewrite"\n' - + 'route = ""\n' + + 'route = "provider_runtime.query_rewrite.max_local"\n' + 'request_timeout_ms = 15000\n', "assisted.max_local.route", ) @@ -1042,7 +1023,6 @@ def test_status_rejects_invalid_max_local_runtime_config() raises: + 'base_url = "http://127.0.0.1:8000/v1"\n' + 'health_url = "http://127.0.0.1:8000/health"\n' + 'model = "max-local-query-rewrite"\n' - + 'route = "provider_runtime.query_rewrite.max_local"\n' + 'request_timeout_ms = 0\n', "assisted.max_local.request_timeout_ms", )