From bdcc3178c5099365351b85be7a2425bd5e3eccee Mon Sep 17 00:00:00 2001 From: huangruiteng <14976749+huangruiteng@users.noreply.github.com> Date: Thu, 17 Sep 2026 03:20:27 +0800 Subject: [PATCH 1/2] fix(status): print the scope beside the projection-route verdict MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `loopx status` and `loopx doctor` both print a `healthy` value for runtime projection routes, but they read different denominators: doctor collects the shared global registry and reports on every route in it, while status scopes the same collector to its own registry and, with `--goal-id`, to a single goal. Neither surface named that scope, so an operator comparing the two read a flat contradiction — doctor red, status green — with nothing in either line to explain it. The projection now carries the route count it was computed over, and both renderers print the registry and denominator beside the flag: - runtime_projection_routes: healthy=False (registry=, goals=44), details=loopx doctor - runtime_projection_routes: healthy=True (registry=, goal=, goals=1) Verified on this machine before the change: `loopx doctor` reported `healthy=False` (44 goals, 13 missing) while `loopx status` reported `healthy=True`; with the fix, an unfiltered `status` reads the same registry as doctor and agrees at `healthy=False (goals=44)`. `runtime_projection_routes` grows by exactly one key. It is a deliberately budgeted hot-path payload, so the scope is kept to the denominator the flag actually needs instead of inlining the full diagnostics; the interface-budget smoke still passes with the dashboard status payload at 19155/19500 chars. Validated: refresh-state shared-runtime projection smoke, shared-runtime material projection smoke, and hot-path interface budget smoke pass; `pytest tests/ -k "status or doctor or projection_route"` reports 311 passed, 1 skipped, with two pre-existing `sqlite-current`/`sqlite-missing` failures reproduced unchanged on origin/main; `loopx check` is clean. Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com> --- .../hot-path-interface-budget-smoke.py | 4 ++- ...h-state-shared-runtime-projection-smoke.py | 25 +++++++++++++++-- ...hared-runtime-material-projection-smoke.py | 4 ++- loopx/control_plane/status/collection.py | 6 ++++- loopx/doctor.py | 5 +++- .../presentation/renderers/status_markdown.py | 27 +++++++++++++++++-- 6 files changed, 63 insertions(+), 8 deletions(-) diff --git a/examples/control_plane/hot-path-interface-budget-smoke.py b/examples/control_plane/hot-path-interface-budget-smoke.py index b06c1e22a..1ee80ecfe 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 38a3f7331..f59b55409 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 f214e9f34..c68313a06 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 9be3e93fb..d979aa6ae 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 8727fde8f..fa8a81919 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 e21d22af9..b7c49de42 100644 --- a/loopx/presentation/renderers/status_markdown.py +++ b/loopx/presentation/renderers/status_markdown.py @@ -134,12 +134,30 @@ def append_global_registry_summary_markdown( def append_runtime_projection_routes_markdown( lines: list[str], diagnostics: dict[str, Any], + *, + registry: Any = None, + goal_id: Any = None, ) -> None: + """Render the flag with the registry and 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 scope is what makes the + two surfaces comparable. + """ healthy = diagnostics.get("healthy") if healthy is None: return + scope: list[str] = [] + if registry: + scope.append(f"registry={registry}") + if goal_id: + scope.append(f"goal={goal_id}") + route_goal_count = diagnostics.get("goal_count") + if isinstance(route_goal_count, int): + scope.append(f"goals={route_goal_count}") + scope_text = f" ({', '.join(scope)})" if scope 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( @@ -950,7 +968,12 @@ def render_status_markdown( if isinstance(payload.get("runtime_projection_routes"), dict) else {} ) - append_runtime_projection_routes_markdown(lines, runtime_projection_routes) + append_runtime_projection_routes_markdown( + lines, + runtime_projection_routes, + registry=payload.get("registry"), + goal_id=payload.get("goal_filter"), + ) event_ledger = ( payload.get("event_ledger_summary") From 73922c28275e0c4f0f448348203d5cefe06021df Mon Sep 17 00:00:00 2001 From: huangruiteng <14976749+huangruiteng@users.noreply.github.com> Date: Thu, 17 Sep 2026 04:01:21 +0800 Subject: [PATCH 2/2] fix(status): keep the route count inside the output budget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first revision of this change printed `registry=...`, `goal=...` and `goals=...` on the projection-route line. That grew the agent-facing markdown rows by 119-125 characters, and `examples/control_plane/cli-output-base-head-differential-smoke.py` allows 32 characters and 64 bytes per row: surface/status/crowded/markdown chars grew by 121; allowance is 32 surface/status/multi_agent/markdown chars grew by 125; allowance is 32 surface/status/small/markdown chars grew by 119; allowance is 32 The line now carries only the denominator — `healthy=False (goals=44)`, `healthy=True (goals=1)` — which is the fact that explains the disagreement: a scoped goal is one route, the fleet is forty-four. The registry stays out of this row because `doctor` already names it along with the full counts map on the unhealthy reading, and the status JSON keeps `registry` at the top level for machine readers. Growing the budget instead would have been a gate change for a presentation fix. Validated: `cli-output-base-head-differential-smoke` ok with base=102, candidate=102, candidate_only=0, review_required=0; the refresh-state shared-runtime projection, shared-runtime material projection and hot-path interface budget smokes pass; `pytest -k "status_markdown or cli_output or projection_route"` reports 85 passed. Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com> --- .../presentation/renderers/status_markdown.py | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/loopx/presentation/renderers/status_markdown.py b/loopx/presentation/renderers/status_markdown.py index b7c49de42..ef037e8cc 100644 --- a/loopx/presentation/renderers/status_markdown.py +++ b/loopx/presentation/renderers/status_markdown.py @@ -134,28 +134,23 @@ def append_global_registry_summary_markdown( def append_runtime_projection_routes_markdown( lines: list[str], diagnostics: dict[str, Any], - *, - registry: Any = None, - goal_id: Any = None, ) -> None: - """Render the flag with the registry and route count it was computed over. + """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 scope is what makes the - two surfaces comparable. + 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 - scope: list[str] = [] - if registry: - scope.append(f"registry={registry}") - if goal_id: - scope.append(f"goal={goal_id}") route_goal_count = diagnostics.get("goal_count") - if isinstance(route_goal_count, int): - scope.append(f"goals={route_goal_count}") - scope_text = f" ({', '.join(scope)})" if scope else "" + 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}{scope_text}{suffix}") @@ -968,12 +963,7 @@ def render_status_markdown( if isinstance(payload.get("runtime_projection_routes"), dict) else {} ) - append_runtime_projection_routes_markdown( - lines, - runtime_projection_routes, - registry=payload.get("registry"), - goal_id=payload.get("goal_filter"), - ) + append_runtime_projection_routes_markdown(lines, runtime_projection_routes) event_ledger = ( payload.get("event_ledger_summary")