Skip to content

fix(diagnostics): distinguish status and doctor route-health scope - #4636

Merged
huangruiteng merged 1 commit into
mainfrom
codex/projection-diagnostic-scope-20260917
Sep 17, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/projection-diagnostic-scope-20260917

Conversation

@huangruiteng

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

status and doctor can 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

  • Tested revision: da75ad88e0bba892f8b495ca38ad7edf872fbd27
  • Run state: finished
  • Input classes: synthetic, public_fixture
Check kind Result Public-safe evidence / limitation
real_entrypoint / regression_parity passed Shared-runtime refresh and material projection smokes exercise real CLI writes/readback. Same routes agree; two registries with equal counts but healthy/lagging results remain distinguishable by actual provenance.
static passed Ruff, configured mypy (22 files), diff hygiene and boundary scan of all seven paths; zero hits.
real_entrypoint passed Hot-path and full CLI base/head output-budget smokes; no budget changes.
integration passed Risk-based premerge: 19 selected checks and 4 direct checks passed, no manual holds. An initial missing TypeScript parser dependency was repaired before this passing rerun.

Exact-diff quality receipt cqr_79a34ae6d4714192de0b is 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

  • Bug fix
  • Test update

LoopX Area

  • Control plane (runtime diagnostics)

Shared-authority RFC fixture impact

N/A: read-only diagnostic metadata; no authority-store or runtime-routing change.

Boundary Checklist

  • No private state, credentials, raw traces, internal links or machine paths.
  • No benchmark execution.
  • Scoped to diagnostics; every commit is DCO signed.

Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_routes envelope 上加 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.

@Job28703

Copy link
Copy Markdown

Independent review at exact head da75ad88e0bba892f8b495ca38ad7edf872fbd27 — English verdict: APPROVE.

Verified by running all three modified smokes plus the budget suite at this head:

  • refresh-state-shared-runtime-projection-smoke passed — including the new counter-example arm that matters most here: two registries with equal goal_count but healthy vs lagging outcomes are distinguishable only by provenance (registry field), which is exactly the "equal counts ≠ equal scope" fix.
  • hot-path-interface-budget-smoke ok; shared-runtime-material-projection-smoke passed.
  • pytest tests/control_plane/test_cli_output_budget.py — 22 passed, confirming "no budget changes": the new (goals=N) suffix and activation_filter line are outside every budgeted surface.
  • Scope metadata is additive (.get() consumers; schema_version stays runtime_projection_route_diagnostics_v0); the doctor no-registry fallback dict (loopx/doctor.py:891-901) gained the same four keys, so the shape doesn't fork; status reuses the existing envelope instead of duplicating scope (status/collection.py:164).

One observable-output change to be aware of on merge: runtime_projection_routes: healthy=X lines now render as healthy=X (goals=N) and the unhealthy suffix changed from details= to global details=loopx doctor — in-repo consumers are updated in this diff.

@huangruiteng
huangruiteng merged commit 3b4839e into main Sep 17, 2026
27 checks passed
@huangruiteng
huangruiteng deleted the codex/projection-diagnostic-scope-20260917 branch September 17, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants