commit 0c1949c227786cb3b75ab13ffde13935798b841a
parent 07be61b48ac53deb4f83b4aa373f22b40786c88f
Author: triesap <tyson@radroots.org>
Date: Thu, 9 Apr 2026 18:37:55 +0000
runtime: report effective hyf diagnostics truth
- clear inactive repo-local roots from startup context
- expose canonical and effective diagnostics directories in runtime status
- add startup and stdio tests for the corrected runtime-truth cases
- keep canonical runtime paths stable while reporting debug override state explicitly
Diffstat:
4 files changed, 130 insertions(+), 0 deletions(-)
diff --git a/src/hyf_runtime/startup.mojo b/src/hyf_runtime/startup.mojo
@@ -8,6 +8,7 @@ from hyf_runtime.env import (
)
from hyf_runtime.errors import raise_runtime_contract_error
from hyf_runtime.paths import RuntimePaths, hyf_runtime_paths_for_unix_profile
+from hyf_runtime.profile import repo_local_profile
@fieldwise_init
@@ -135,6 +136,8 @@ def resolve_startup_context(
if overrides.startup_config_path != "":
startup_config_path = String(overrides.startup_config_path)
startup_config_path_source = String("startup_flag")
+ if profile != repo_local_profile():
+ repo_local_base_root = String("")
return RuntimeStartupContext(
paths_profile=profile,
diff --git a/src/hyf_runtime/status.mojo b/src/hyf_runtime/status.mojo
@@ -1,5 +1,9 @@
from mojson import Value, loads
+from hyf_runtime.diagnostics import (
+ diagnostics_debug_override_dir_from_env,
+ effective_diagnostics_dir_for_runtime_paths,
+)
from hyf_runtime.secrets import (
default_secret_backend_name,
identity_material_created_by_startup,
@@ -47,6 +51,7 @@ def build_runtime_status_value(context: RuntimeStartupContext) raises -> Value:
config.set("compiled_defaults_active", Value(True))
status.set("config", config)
+ status.set("diagnostics", _diagnostics_status_value(context))
status.set("secret_storage", _secret_storage_status_value(context))
status.set(
"protected_local_data", _protected_local_data_status_value(context)
@@ -78,6 +83,20 @@ def _secret_storage_status_value(
return secret_storage^
+def _diagnostics_status_value(context: RuntimeStartupContext) raises -> Value:
+ var diagnostics = loads("{}")
+ var debug_override_dir = diagnostics_debug_override_dir_from_env()
+ diagnostics.set(
+ "canonical_dir", Value(String(context.paths.diagnostics_dir))
+ )
+ diagnostics.set(
+ "effective_dir",
+ Value(effective_diagnostics_dir_for_runtime_paths(context.paths)),
+ )
+ diagnostics.set("debug_override_active", Value(debug_override_dir != ""))
+ return diagnostics^
+
+
def _protected_local_data_status_value(
context: RuntimeStartupContext,
) raises -> Value:
diff --git a/tests/test_runtime_paths.mojo b/tests/test_runtime_paths.mojo
@@ -144,6 +144,24 @@ def test_startup_context_cli_flags_override_env() raises:
)
+def test_startup_context_clears_inactive_repo_local_root() raises:
+ var context = resolve_startup_context(
+ RuntimeStartupInput(
+ env_paths_profile="interactive_user",
+ env_repo_local_base_root="/tmp/hyf-runtime",
+ user_home="/home/hyf-test",
+ argv=_startup_argv2("--repo-local-root", "/tmp/hyf-override"),
+ )
+ )
+
+ assert_equal(context.paths_profile, "interactive_user")
+ assert_equal(context.repo_local_base_root, "")
+ assert_equal(
+ context.paths.config_path,
+ "/home/hyf-test/.radroots/config/services/hyf/config.toml",
+ )
+
+
def test_startup_context_config_flag_overrides_config_artifact_only() raises:
var context = resolve_startup_context(
RuntimeStartupInput(
diff --git a/tests/test_stdio_contract.mojo b/tests/test_stdio_contract.mojo
@@ -22,6 +22,7 @@ from stdio_process_helper import (
comptime _EXPECTED_INTERNAL_ERROR_MESSAGE = (
"internal hyf daemon error; inspect local diagnostics"
)
+comptime _HYF_DIAGNOSTICS_DIR_ENV = "HYF_DIAGNOSTICS_DIR"
def _has_key(value: Value, key: String) -> Bool:
@@ -101,6 +102,24 @@ def test_status_reports_repo_local_runtime_truth() raises:
temp_dir + "/logs/services/hyf/diagnostics",
)
assert_equal(
+ response["output"]["runtime"]["diagnostics"][
+ "canonical_dir"
+ ].string_value(),
+ temp_dir + "/logs/services/hyf/diagnostics",
+ )
+ assert_equal(
+ response["output"]["runtime"]["diagnostics"][
+ "effective_dir"
+ ].string_value(),
+ temp_dir + "/logs/services/hyf/diagnostics",
+ )
+ assert_equal(
+ response["output"]["runtime"]["diagnostics"][
+ "debug_override_active"
+ ].bool_value(),
+ False,
+ )
+ assert_equal(
response["output"]["runtime"]["secret_storage"][
"default_backend"
].string_value(),
@@ -180,6 +199,77 @@ def test_status_reports_repo_local_runtime_truth() raises:
)
+def test_status_clears_repo_local_root_outside_repo_local_profile() raises:
+ with TemporaryDirectory() as temp_dir:
+ with ScopedEnvVar(HYF_PATHS_PROFILE_ENV, "interactive_user"):
+ 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"),
+ )
+
+ assert_equal(
+ response["output"]["runtime"][
+ "paths_profile"
+ ].string_value(),
+ "interactive_user",
+ )
+ assert_equal(
+ response["output"]["runtime"][
+ "repo_local_base_root"
+ ].string_value(),
+ "",
+ )
+ assert_true(
+ response["output"]["runtime"]["paths"][
+ "config_path"
+ ].string_value().find(temp_dir)
+ < 0
+ )
+
+
+def test_status_reports_effective_diagnostics_override_truthfully() raises:
+ with TemporaryDirectory() as temp_dir:
+ var diagnostics_override_dir = (
+ Path(temp_dir) / "debug-diagnostics-override"
+ )
+ with ScopedEnvVar(HYF_PATHS_PROFILE_ENV, "repo_local"):
+ with ScopedEnvVar(HYF_PATHS_REPO_LOCAL_ROOT_ENV, temp_dir):
+ with ScopedEnvVar(
+ _HYF_DIAGNOSTICS_DIR_ENV,
+ diagnostics_override_dir.__fspath__(),
+ ):
+ var response = run_stdio_entrypoint(
+ "src/main.mojo",
+ load_scenario_request_json("scenarios/status_ok.json"),
+ )
+
+ assert_equal(
+ response["output"]["runtime"]["paths"][
+ "diagnostics_dir"
+ ].string_value(),
+ temp_dir + "/logs/services/hyf/diagnostics",
+ )
+ assert_equal(
+ response["output"]["runtime"]["diagnostics"][
+ "canonical_dir"
+ ].string_value(),
+ temp_dir + "/logs/services/hyf/diagnostics",
+ )
+ assert_equal(
+ response["output"]["runtime"]["diagnostics"][
+ "effective_dir"
+ ].string_value(),
+ diagnostics_override_dir.__fspath__(),
+ )
+ assert_equal(
+ response["output"]["runtime"]["diagnostics"][
+ "debug_override_active"
+ ].bool_value(),
+ True,
+ )
+
+
def test_capabilities_success() raises:
var response = run_hyf_stdio(
load_scenario_request_json("scenarios/capabilities_ok.json")