hyf

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

commit 1f3dac0bc20f065317fe5a49c9e2b237cd33c3c8
parent 5d92a15c7136d0f4556537769e249bda4a070325
Author: triesap <tyson@radroots.org>
Date:   Mon, 21 Sep 2026 13:41:02 +0000

runtime: add a TypeSafe runtime profile

Diffstat:
Msrc/hyf_runtime/config.mojo | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Mtests/test_runtime_paths.mojo | 50+++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 114 insertions(+), 7 deletions(-)

diff --git a/src/hyf_runtime/config.mojo b/src/hyf_runtime/config.mojo @@ -39,13 +39,29 @@ struct HyfMaxLocalProviderRuntimeConfig(Defaultable, Copyable, Movable): @fieldwise_init +struct HyfTypesafeProviderRuntimeConfig(Defaultable, Copyable, Movable): + var enabled: Bool + var base_url: String + var model: String + var request_timeout_ms: Int + + def __init__(out self): + self.enabled = False + self.base_url = "https://api.typesafe.ai" + self.model = "jev-1.13.0" + self.request_timeout_ms = 15000 + + +@fieldwise_init struct HyfAssistedRuntimeConfig(Defaultable, Copyable, Movable): var provider: String var max_local: HyfMaxLocalProviderRuntimeConfig + var typesafe: HyfTypesafeProviderRuntimeConfig def __init__(out self): self.provider = "" self.max_local = HyfMaxLocalProviderRuntimeConfig() + self.typesafe = HyfTypesafeProviderRuntimeConfig() @fieldwise_init @@ -90,10 +106,20 @@ def assisted_execution_enabled(config: HyfLoadedRuntimeConfig) -> Bool: def assisted_runtime_configured(config: HyfLoadedRuntimeConfig) -> Bool: + if not config.effective.runtime.allow_assisted: + return False + if config.effective.assisted.provider == "max_local": + return config.effective.assisted.max_local.enabled + if config.effective.assisted.provider == "typesafe": + return config.effective.assisted.typesafe.enabled + return False + + +def typesafe_provider_configured(config: HyfLoadedRuntimeConfig) -> Bool: return ( config.effective.runtime.allow_assisted - and config.effective.assisted.provider == "max_local" - and config.effective.assisted.max_local.enabled + and config.effective.assisted.provider == "typesafe" + and config.effective.assisted.typesafe.enabled ) @@ -145,13 +171,31 @@ def _validate_runtime_config(config: HyfRuntimeConfig) raises: ) if config.runtime.allow_assisted: - if config.assisted.provider != "max_local": + if ( + config.assisted.provider != "max_local" + and config.assisted.provider != "typesafe" + ): raise Error( - "assisted.provider must be 'max_local' when runtime.allow_assisted is true" + "assisted.provider must be 'max_local' or 'typesafe' when runtime.allow_assisted is true" ) - if config.assisted.provider != "" and config.assisted.provider != "max_local": - raise Error("assisted.provider must be 'max_local'") + if ( + config.assisted.provider != "" + and config.assisted.provider != "max_local" + and config.assisted.provider != "typesafe" + ): + raise Error("assisted.provider must be 'max_local' or 'typesafe'") + + if config.assisted.typesafe.enabled: + if not config.runtime.allow_assisted: + raise Error( + "runtime.allow_assisted must be true when assisted.typesafe.enabled is true" + ) + if config.assisted.provider != "typesafe": + raise Error( + "assisted.provider must be 'typesafe' when assisted.typesafe.enabled is true" + ) + _validate_typesafe_provider_config(config.assisted.typesafe) if config.assisted.max_local.enabled: if not config.runtime.allow_assisted: @@ -326,6 +370,21 @@ def _reject_removed_max_local_route_config(config_text: String) raises: ) +def _validate_typesafe_provider_config( + config: HyfTypesafeProviderRuntimeConfig +) raises: + _require_non_empty(config.base_url, "assisted.typesafe.base_url") + _require_no_boundary_whitespace( + config.base_url, "assisted.typesafe.base_url" + ) + if not config.base_url.startswith("https://"): + raise Error("assisted.typesafe.base_url must use https") + _require_non_empty(config.model, "assisted.typesafe.model") + _require_no_boundary_whitespace(config.model, "assisted.typesafe.model") + if config.request_timeout_ms <= 0: + raise Error("assisted.typesafe.request_timeout_ms must be greater than zero") + + def _validate_max_local_provider_config( config: HyfMaxLocalProviderRuntimeConfig ) raises: diff --git a/tests/test_runtime_paths.mojo b/tests/test_runtime_paths.mojo @@ -1,5 +1,5 @@ from std.collections import List -from std.testing import TestSuite, assert_equal, assert_raises +from std.testing import TestSuite, assert_equal, assert_raises, assert_true from hyf_runtime.env import ( hyf_paths_profile_env_name, @@ -214,3 +214,51 @@ def test_startup_context_rejects_missing_root_unknown_flag_and_flag_as_value() r def main() raises: TestSuite.discover_tests[__functions_in_module()]().run() + + +from hyf_runtime.config import ( + HyfAssistedRuntimeConfig, + HyfExecutionRuntimeConfig, + HyfLoadedRuntimeConfig, + HyfMaxLocalProviderRuntimeConfig, + HyfRuntimeConfig, + HyfServiceRuntimeConfig, + HyfTypesafeProviderRuntimeConfig, + assisted_runtime_configured, + typesafe_provider_configured, +) + + +def _typesafe_config(enabled: Bool, base_url: String) -> HyfLoadedRuntimeConfig: + return HyfLoadedRuntimeConfig( + artifact_present=True, + loaded=True, + compiled_defaults_active=False, + load_state="loaded", + load_error="", + effective=HyfRuntimeConfig( + service=HyfServiceRuntimeConfig(transport="stdio"), + runtime=HyfExecutionRuntimeConfig( + default_execution_mode="deterministic", allow_assisted=True + ), + assisted=HyfAssistedRuntimeConfig( + provider="typesafe", + max_local=HyfMaxLocalProviderRuntimeConfig(), + typesafe=HyfTypesafeProviderRuntimeConfig( + enabled=enabled, + base_url=base_url, + model="jev-1.13.0", + request_timeout_ms=15000, + ), + ), + ), + ) + + +def test_typesafe_profile_is_configured_and_pins_https_model() raises: + var config = _typesafe_config(True, "https://api.typesafe.ai") + assert_true(assisted_runtime_configured(config)) + assert_true(typesafe_provider_configured(config)) + assert_equal(config.effective.assisted.typesafe.model, "jev-1.13.0") + var disabled = _typesafe_config(False, "https://api.typesafe.ai") + assert_true(not assisted_runtime_configured(disabled))