fix(diagnostics): distinguish status and doctor route-health scope - #4636
Conversation
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
huangruiteng
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Reviewed exact head: da75ad88e0bba892f8b495ca38ad7edf872fbd27 (codex/status-doctor-route-health).
动机
status 与 doctor 可能报出不同的 route health,因为它们读的注册表或 Goal 范围不同;而计数相同并不等于范围相同。旧输出只给 healthy,于是操作者无法判断「两个面不一致」到底是范围差异还是真的退化。这正是这类诊断最容易误导人的地方。
改动把「我量的是哪个范围」变成输出的一部分:diagnostics payload 带上 registry / runtime_root / goal_filter / activation_state_filter,status 复用既有 scope envelope 增列 goal_count,doctor 打上 registry/goals/counts 并把自己标成 global drill-down。
改动思路
入口是 collect_runtime_projection_route_diagnostics(唯一 health 计算权威,本次不改其判定逻辑),由 collect_status 与 collect_doctor 各自消费:status 把 goal_count 加进既有 envelope,doctor 在 markdown 里补 provenance,status markdown 把 details=loopx doctor 改成 global details=loopx doctor 并加上 goals=<count>。作者明确说明这次没有引入第二套 health 权威、scope 指纹或热路径上的重复 scope 对象——这几点在 diff 里成立:改动是「把 collector 自己已经用到的输入接到返回收据上」,不是新机制。
具体改动
7 个文件、+58/-8:payload 四个 provenance 字段、status envelope 的 goal_count、两处 renderer 文本,以及三个 smoke 从「== {"healthy": True}」改成断言 provenance 关系。
我跑了三个真实入口 smoke,全部通过:refresh-state-shared-runtime-projection-smoke(passed)、shared-runtime-material-projection-smoke(passed)、hot-path-interface-budget-smoke(ok,top_level_keys=25/25,说明新增字段是嵌套的、没有顶破接口预算)。
其中 refresh-state smoke 的新断言正是这条 PR 的核心语义,我读了实现:
- 同一批路由在 status 与 doctor 上的
healthy/goal_count必须一致; - doctor 的 registry 必须等于共享 runtime 的 global registry,而 status 的 registry 等于本次选中的 source registry,两者必须不同——「计数相同、范围不同」因此可被区分;
- 另写一个不相关工程/注册表,其 healthy 结果的
goal_count与 lagging 的那个相同,但 registry 字符串不同,仍可区分; - markdown 断言包含
goals=1、registry: ...、goal_filter: ...、global details=loopx doctor,doctor markdown 含registry=…、goals=、counts=。
关键内容讲解
runtime_projection_route.py:694:payload 增加registry(解析后绝对路径)、runtime_root、goal_filter、activation_state_filter(经normalize_goal_activation_state归一化)——都是 collector 实际使用的输入,不是重新推导的。status/collection.py:159:只在既有runtime_projection_routesenvelope 上加goal_count,保持「复用 status 既有 scope」而不是新增 scope 对象。status_markdown.py:142:输出healthy=False (goals=1), global details=loopx doctor——global一词明确区分了「doctor 是全局面板」而不是同范围复述。doctor.py:1190:健康行后追加registry=…, goals=…, counts=…。
对主干的风险
测试-only 意义上没有风险面外的改动:health 判定、route 解析、Goal 选择、权限与 provider 行为都没动,前端也没有消费 runtime_projection_routes(作者已说明,且我在 diff 中未见前端路径)。
一条 P3(F1,非阻塞):同一个值出现了两个名字。status markdown 打的是 activation_filter:(取自 goal_projection.scope,而 collection.py:198 把该 scope 设为 activation_filter.value),而同一份 diagnostics payload 暴露的字段名是 activation_state_filter(runtime_projection_route.py:700-702)。读者对照 JSON 与 Markdown 会以为这是两个不同的过滤条件——而消除这类 scope 歧义正是本 PR 的目的;smoke 也没有断言那个 markdown 标签,所以不一致不会被发现。建议统一命名(markdown 用 payload 的字段名,或把 payload 字段改成与 envelope 一致),并在某个 smoke 里断言该标签。
另外记录一条不是问题的点:payload 现在带 registry/runtime_root 绝对路径。status 早就在打印 registry 路径(status_markdown.py:60),所以这与既有输出面一致;只是提醒操作者不要把 doctor/status 的 JSON 直接贴进公开产物。
我的整体评价
结论 APPROVE(本 PR 由维护者本人所有,GitHub 不允许正式自我批准,故以 COMMENTED 评审记录批准结论)。改动方向准确:把「范围」作为诊断输出的一部分,让「计数相同但范围不同」这件事在操作面上可区分、可归因;实现上复用了 collector 已有输入与 status 既有 envelope,没有引入第二套权威或热路径开销。我跑了三个真实入口 smoke(含新加的两注册表对照与 markdown 断言),并确认接口预算未被顶破。回退成本是几个字段与两行文本。
唯一 P3 是同一值的两个命名,非阻塞但值得顺手统一。
English verdict: APPROVE - exact head da75ad8; the route-health diagnostics now carry the registry, runtime root, goal filter and activation filter they actually used, status reuses its existing envelope to add goal_count, and doctor labels itself the global drill-down with registry/goals/counts, so "equal counts, different scope" becomes distinguishable. I ran the three real-entrypoint smokes (refresh-state shared-runtime projection, shared-runtime material projection, hot-path interface budget) - all pass, with the new assertions covering same-route agreement, registry inequality between the two surfaces, and an unrelated registry whose equal goal_count is still separable. One non-blocking P3: the same activation value is rendered as activation_filter in status markdown but exposed as activation_state_filter in the payload.
|
Independent review at exact head Verified by running all three modified smokes plus the budget suite at this head:
One observable-output change to be aware of on merge: |
Goal And Delivered Outcome
statusanddoctorcan report different route health because they read different registries or Goal scopes. Equal counts do not establish equal scope. This replaces #4594: retain the compact count, expose the actual diagnostic registry/runtime/filter metadata, reuse status's existing scope envelope, and label doctor as a global drill-down.Scope And Continuation
Complete within diagnostic interpretation. The existing collector still owns the health calculation; no route resolution, projection writes, Goal selection, permissions or provider behavior changes. The related simplification pass avoids a second health authority, scope fingerprint and duplicate scope object on the hot path.
Validation
da75ad88e0bba892f8b495ca38ad7edf872fbd27Exact-diff quality receipt
cqr_79a34ae6d4714192de0bis valid for 7 files; no blockers/warnings/advisories, safe-fix allowed but not used. No live model or benchmark jobs were run. Maintainer review and merge remain required.Frontend / Visual Evidence
UI impact: none. CLI Markdown and diagnostic JSON change. The packaged frontend has no consumer of
runtime_projection_routes; no settings or Lark companion is required. Health remains a scoped observation, not Goal acceptance.Type of Change
LoopX Area
Shared-authority RFC fixture impact
N/A: read-only diagnostic metadata; no authority-store or runtime-routing change.
Boundary Checklist