diff --git a/examples/control_plane/hot-path-interface-budget-smoke.py b/examples/control_plane/hot-path-interface-budget-smoke.py index b06c1e22a3..1ee80ecfeb 100644 --- a/examples/control_plane/hot-path-interface-budget-smoke.py +++ b/examples/control_plane/hot-path-interface-budget-smoke.py @@ -387,7 +387,9 @@ def main() -> int: status_items = status_payload["attention_queue"]["items"] assert status_items, status_payload assert "task_graph_projection" not in status_items[0], status_items[0] - assert status_payload["runtime_projection_routes"] == {"healthy": True} + route_health = status_payload["runtime_projection_routes"] + assert route_health["healthy"] is True, route_health + assert route_health["goal_count"] >= 1, route_health quota_payload = build_quota_should_run( status_payload, goal_id=GOAL_ID, diff --git a/examples/control_plane/refresh-state-shared-runtime-projection-smoke.py b/examples/control_plane/refresh-state-shared-runtime-projection-smoke.py index 38a3f73313..f59b554099 100644 --- a/examples/control_plane/refresh-state-shared-runtime-projection-smoke.py +++ b/examples/control_plane/refresh-state-shared-runtime-projection-smoke.py @@ -25,6 +25,7 @@ resolve_runtime_projection_route, ) from loopx import doctor as doctor_module # noqa: E402 +from loopx.paths import global_registry_path # noqa: E402 from loopx.presentation.renderers.status_markdown import ( # noqa: E402 render_status_markdown, ) @@ -387,8 +388,10 @@ def main() -> None: shared_runtime=shared_runtime, ) route_diagnostics = status["runtime_projection_routes"] - assert route_diagnostics == {"healthy": True}, route_diagnostics + assert route_diagnostics["healthy"] is True, route_diagnostics + assert route_diagnostics["goal_count"] == 1, route_diagnostics assert "runtime_projection_routes: healthy=True" in render_status_markdown(status) + assert "goals=1" in render_status_markdown(status), render_status_markdown(status) source_index = project_runtime / "goals" / GOAL_ID / "runs" / "index.jsonl" source_rows = [ @@ -420,7 +423,8 @@ def main() -> None: shared_runtime=shared_runtime, ) lagging_routes = lagging_status["runtime_projection_routes"] - assert lagging_routes == {"healthy": False}, lagging_routes + assert lagging_routes["healthy"] is False, lagging_routes + assert lagging_routes["goal_count"] == 1, lagging_routes lagging_markdown = render_status_markdown(lagging_status) assert "runtime_projection_routes: healthy=False" in lagging_markdown assert "details=loopx doctor" in lagging_markdown @@ -437,6 +441,23 @@ def main() -> None: item.get("goal_id") == GOAL_ID and item.get("status") == "lagging" for item in doctor_routes["items"] ), doctor_routes + # The operator-visible disagreement this guards against: `status` and + # `doctor` print the same `healthy` key, so they have to agree about the + # scope they read, and each surface has to name that scope in its + # rendered line instead of leaving a bare boolean. + assert doctor_routes["healthy"] is lagging_routes["healthy"], ( + doctor_routes, + lagging_routes, + ) + assert doctor_routes["goal_count"] == lagging_routes["goal_count"], ( + doctor_routes, + lagging_routes, + ) + doctor_markdown = doctor_module.render_doctor_markdown(doctor) + assert "runtime_projection_routes_healthy: `False`" in doctor_markdown + assert f"registry=`{global_registry_path(shared_runtime)}`" in doctor_markdown, doctor_markdown + assert f"goals=`{doctor_routes['goal_count']}`" in doctor_markdown, doctor_markdown + assert "counts=`" in doctor_markdown, doctor_markdown single_runtime = Path(tmp) / "single-runtime" single_registry, single_goal = write_route_source( diff --git a/examples/control_plane/shared-runtime-material-projection-smoke.py b/examples/control_plane/shared-runtime-material-projection-smoke.py index f214e9f348..c68313a060 100644 --- a/examples/control_plane/shared-runtime-material-projection-smoke.py +++ b/examples/control_plane/shared-runtime-material-projection-smoke.py @@ -264,7 +264,9 @@ def exercise_split_runtime(root: Path) -> None: assert dream_status["run_history"]["goals"][0]["latest_status_run"][ "classification" ] == "dreaming_proposal_deferred" - assert dream_status["runtime_projection_routes"] == {"healthy": True} + route_health = dream_status["runtime_projection_routes"] + assert route_health["healthy"] is True, route_health + assert route_health["goal_count"] >= 1, route_health source_row = read_rows(source_runtime)[-1] replay_record, replay_index = build_shared_runtime_material_projection( diff --git a/loopx/control_plane/status/collection.py b/loopx/control_plane/status/collection.py index 9be3e93fba..d979aa6ae2 100644 --- a/loopx/control_plane/status/collection.py +++ b/loopx/control_plane/status/collection.py @@ -159,7 +159,11 @@ def collect_status( bool(runtime_projection_routes.get("healthy")) if runtime_projection_routes.get("available") else None - ) + ), + # The flag is only readable next to its denominator: `doctor` reports + # the same key over the shared global registry, so a scoped `status` + # run has to name how many routes it actually checked. + "goal_count": int(runtime_projection_routes.get("goal_count") or 0), } contract_projection = { "ok": contract.get("ok"), diff --git a/loopx/doctor.py b/loopx/doctor.py index 8727fde8f5..fa8a819190 100644 --- a/loopx/doctor.py +++ b/loopx/doctor.py @@ -1186,7 +1186,10 @@ def render_doctor_markdown(payload: dict[str, Any]) -> str: f"- skill_delivery_mode: `{(payload.get('skill_delivery') or {}).get('mode')}`", f"- skill_delivery_status: `{(payload.get('skill_delivery') or {}).get('status')}`", f"- global_registry_writable: `{(payload.get('global_registry_writability') or {}).get('ok')}`", - f"- runtime_projection_routes_healthy: `{(payload.get('runtime_projection_routes') or {}).get('healthy')}`", + f"- runtime_projection_routes_healthy: `{(payload.get('runtime_projection_routes') or {}).get('healthy')}`" + f" (registry=`{(payload.get('global_registry_writability') or {}).get('path')}`," + f" goals=`{(payload.get('runtime_projection_routes') or {}).get('goal_count')}`," + f" counts=`{json.dumps((payload.get('runtime_projection_routes') or {}).get('counts') or {}, ensure_ascii=False, sort_keys=True)}`)", f"- user_local_bin_on_path: `{(payload.get('path') or {}).get('user_local_bin_on_path')}`", f"- python: `{(payload.get('python') or {}).get('executable')}`", f"- typescript_control_plane: `{typescript_control_plane.get('status')}`", diff --git a/loopx/presentation/renderers/status_markdown.py b/loopx/presentation/renderers/status_markdown.py index e21d22af90..ef037e8cc2 100644 --- a/loopx/presentation/renderers/status_markdown.py +++ b/loopx/presentation/renderers/status_markdown.py @@ -135,11 +135,24 @@ def append_runtime_projection_routes_markdown( lines: list[str], diagnostics: dict[str, Any], ) -> None: + """Render the flag beside the route count it was computed over. + + `doctor` derives the same `healthy` key from the shared global registry, so + a bare boolean here can read as a contradiction. The denominator is the one + fact that explains it: `goals=1` is a single scoped goal, `goals=44` is the + fleet. The registry itself stays out of this line because the agent-facing + output budget allows only 32 extra characters per row, and `doctor` already + names the registry and the full counts map for the unhealthy reading. + """ healthy = diagnostics.get("healthy") if healthy is None: return + route_goal_count = diagnostics.get("goal_count") + scope_text = ( + f" (goals={route_goal_count})" if isinstance(route_goal_count, int) else "" + ) suffix = "" if healthy else ", details=loopx doctor" - lines.append(f"- runtime_projection_routes: healthy={healthy}{suffix}") + lines.append(f"- runtime_projection_routes: healthy={healthy}{scope_text}{suffix}") def append_global_registry_findings_markdown(