Skip to content

fix(cli): show why diagnose and upgrade-plan collection failed in Markdown output - #9696

Open
mojunzi wants to merge 2 commits into
loopx-project:mainfrom
mojunzi:codex/diagnose-upgrade-plan-markdown-errors
Open

mojunzi wants to merge 2 commits into
loopx-project:mainfrom
mojunzi:codex/diagnose-upgrade-plan-markdown-errors

Conversation

@mojunzi

@mojunzi mojunzi commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

  • Outcome basis / optional anchor: reproduced defect; no existing issue or PR found.
  • Goal/source and gap: when diagnose or upgrade-plan cannot collect (for example because the registry is not valid JSON), the payload is ok: false with the exception text in error. The Markdown renderers print ok, the null fields, and a generic recommended_action, but omit error. The default Markdown output therefore reports that collection failed without stating why, while JSON carries the reason.
  • Observable before → after, with the validation row that proves it:
    • Before: with a corrupt registry, loopx diagnose --goal-id G and loopx upgrade-plan --goal-id G omitted error in Markdown output.
    • After: both render - error: <markdown_scalar(error)> directly after - ok: False whenever error is present, leaving successful output unchanged (unit and real_entrypoint rows below).
  • Issue/task and intended base: none; main.

Author Declaration

  • Written by: model_agent (Claude, Anthropic & Gemini, Google), reviewed by the submitting human operator.

Implemented against

Criterion (spec clause) Disposition Symbol / path Test or command
A failed diagnose collection's Markdown includes the JSON error implemented loopx/presentation/renderers/diagnose_markdown.py::render_diagnosis_markdown tests/test_markdown_failure_reason.py
A failed upgrade-plan collection's Markdown includes the JSON error implemented loopx/upgrade.py::render_upgrade_plan_markdown tests/test_markdown_failure_reason.py
Successful output is unchanged implemented line emitted only when payload.get("error") is truthy verified unchanged for healthy registered Goals

Scope And Continuation

  • Completed scope and remaining work: complete within this scope.
  • Slice boundary / successor: N/A — self-contained bug fix.

Validation

  • Tested revision: 214d757cd
  • Run state: finished
  • Input classes: synthetic
Check kind Result Public-safe evidence / limitation
unit passed tests/test_markdown_failure_reason.py (both commands fail on base and pass on 214d757cd; verified on Python 3.13/3.14 prior to rebase and re-verified on 214d757cd with Python 3.15).
static passed py_compile and git diff --check clean on all 3 files.
real_entrypoint passed loopx.cli:main for diagnose and upgrade-plan against a corrupt registry emits - error: <json error> in Markdown; exit 1.
  • Coverage and gaps: verified on macOS; logic is OS-independent. Full CI pytest/ruff will also run on the PR.

Frontend / Visual Evidence

  • UI impact: none
  • Before: N/A
  • After: N/A
  • First viewport and preview: N/A
  • States and viewports shown: N/A
  • Source data: none
  • Attention review: N/A
  • Craft review: N/A

Type of Change

  • Bug fix

LoopX Area

  • Public docs or presentation surface (README, protocols, dashboard)

Technical Direction

  • Direction / acceptance reference, when applicable: Core control-plane hardening

Shared-authority RFC fixture impact

N/A

Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md).
  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.
  • I kept the change scoped to the linked issue/task.
  • Existing English/Chinese RFC pairs (including ledger entries) both have a diff, and the local premerge check python3 scripts/check_rfc_bilingual.py --base origin/main --head HEAD passes, or no paired RFC changed.
  • I completed the visual evidence section for UI changes, or marked UI impact none.
  • Every commit includes a DCO Signed-off-by trailer (git commit -s).

…kdown

When diagnose or upgrade-plan fails collection (for example on a corrupt
registry), the JSON payload carries the failure reason in error, while
render_diagnosis_markdown and render_upgrade_plan_markdown omitted it.

Emit - error: <markdown_scalar(error)> right after - ok: when error is
present in both renderers.

Signed-off-by: Wang, Xiang-Han <[email protected]>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 01:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

动机 / Motivation

终端用户排查注册表故障时,需要 diagnose 和 upgrade-plan 显示收集失败的实际原因。旧 Markdown 只给通用提示,还须切换到 JSON 才能知道具体失败。候选在 Markdown 的 ok 字段后显示原有错误原因。变更范围是两个命令的失败展示,成功展示和退出码沿用已有契约。当前实现使 upgrade.py 增至 1,065 行,触发 1,062 行预算门禁。

改动思路 / Approach

保留原 handler 生成的错误载荷及退出状态。两个 Markdown renderer 在 error 非空时调用已有的 markdown_scalar。 沿用当前 presenter 层与标量格式化,避免增加处于预算上限的模块。 原命令继续持有读和状态判断逻辑。渲染错误不改变注册表、迁移权限或调度。 变更范围是两个命令的失败展示,成功展示和退出码沿用已有契约。

具体改动 / Changes

审阅提交 214d757,diff 基线 21c6ddf,3 个文件,+35/-1。两个 renderer 使用同一格式化 helper,新增测试沿正常 CLI 入口读取失败原因。目标分支快照为 1bdf851,调用路径与有效 diff 基线一致。diagnose 直接在 ok 后插入错误行,upgrade-plan 还拆开原 bullet 组,因而会多出三行。新测试先取 JSON 的原始 error,再调用同一实际 Markdown 入口查找该文本,没有给收集器预置返回值。 完整 diff 预算触发行

对主干的风险 / Risks

[P2] 保留 upgrade.py 的现有模块行数上限。 该模块在冻结基线为 1,062 行,当前提交增至 1,065 行,导致标准预合并门禁失败。请保留两处可见错误,把 upgrade.py 控制在现有预算内,并重跑 premerge。

实际 console script 在损坏注册表和未迁移 Goal 上保留退出 1 与原 JSON,只增加错误行。健康 Goal 的 diagnose 和空清单的 upgrade-plan 均退出 0,成功 Markdown 与基线逐字一致。 同输入对照可独立复现失败和成功分支。维护预算比对只新增 upgrade.py 的 1,065/1,062 违规,status.py 的 1,343/1,339 在两边一致。 121 项定向和邻近测试、另 5 项 diagnose 契约,以及 Ruff、编译和 diff 检查通过。标准 premerge 的 module_ceiling_colocation 失败。

我的整体评价 / Verdict

REQUEST_CHANGES。 用户可见修复已独立复现。请修复本次引入的标准模块门禁失败后再复核。 本次仅涉及 CLI 与构建输出,没有图形界面需要复核。运行范围为 macOS 和本地合成注册表。

English verdict: REQUEST_CHANGES at 214d757. Both CLI fixes work, but the patch increases upgrade.py from 1,062 to 1,065 lines and introduces a blocking local module-budget regression.

Comment thread loopx/upgrade.py Outdated
"",
*_bullet_fields(payload, ("ok", "registry", "runtime_root", "cli_bin")),
*_bullet_fields(payload, ("ok",)),
*([f"- error: {markdown_scalar(payload.get('error'))}"] if payload.get("error") else []),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] 保留现有模块行数上限。该提交使 upgrade.py 从 1,062 行增至 1,065 行,标准 premerge 新增 module_ceiling_colocation 失败。基线相同检查只报 status.py。保持错误行和退出码,将 upgrade.py 恢复到现有 1,062 行预算后重跑标准门禁。

…n layer

Extract render_upgrade_plan_markdown and its Markdown field helpers from
loopx/upgrade.py into loopx/presentation/renderers/upgrade_plan_markdown.py
while re-exporting render_upgrade_plan_markdown from loopx.upgrade.

This keeps loopx/upgrade.py within its 1,062-line frozen ceiling (959 lines)
so module_ceiling_colocation passes while preserving both diagnose and
upgrade-plan Markdown error output and existing success rendering parity.

Signed-off-by: Wang, Xiang-Han <[email protected]>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

动机 / Motivation

使用 diagnose 和 upgrade-plan 排查本地安装及 Goal 状态的操作者。 采集失败的 JSON 有 error,默认 Markdown 只有 ok=False。旧候选显示错误但使 upgrade.py 从 1,062 增至 1,065 行。 真实 CLI 子进程读同一个损坏的合成 registry,两个命令在新提交以退出码 1 取得与 JSON 相同的失败理由。 两个现有终端命令的失败信息和成功输出,升级采集沿用原 owner。 本轮验证本地 macOS 源码入口、合成 registry 与渲染 payload。未执行安装升级,也未触发托管 CI。 上轮预算发现

改动思路 / Approach

将 upgrade-plan 的纯格式化从升级采集分出,并从原模块导出同一函数。两个渲染器沿已有 markdown_scalar 转换失败理由。 两个现有终端命令的失败信息和成功输出,升级采集沿用原 owner。 包含提示警告、安装清单、迁移和 deferred 状态的合成成功输入在两个渲染器均得到逐字相同的基线与新输出。

具体改动 / Changes

精确提交 964e97ef9d141a6c1786bf1385c1686e1b128ae6,基线 1bdf851e9447bc7c22ab29d10948a674bf4687c4。四文件 +221/-106;upgrade.py 从 1,062 减至 959 行。 与当前主干 086afeef45f35034eb4147062bc2e25df41a767f 合成时这四条路径与评审提交逐字一致。依据 docs/development/testing-and-quality.md 核对 错误读回、成功输出和模块预算。 预算规范

关键代码讲解

diagnose 对已有 error 插入一条 Markdown 行。upgrade-plan 复用同一 scalar,并从原 upgrade 模块保留对 Presentation renderer 的重导出。采集和渲染各只有一个 owner。 诊断 · 升级计划 renderer

对主干的风险 / Risks

基线两个命令均退出 1 且 JSON 有理由,Markdown 无错误行。新提交的合成换行和竖线仍整形在一条错误行里。 包含提示警告、安装清单、迁移和 deferred 状态的合成成功输入在两个渲染器均得到逐字相同的基线与新输出。 定向 127 项通过,标准预检和 module_ceiling_colocation 通过,有一项非阻塞维护性建议。 本轮验证本地 macOS 源码入口、合成 registry 与渲染 payload。未执行安装升级,也未触发托管 CI。

我的整体评价 / Verdict

批准。 两项错误显示正常,健康输出和既有导入保留。抽离后的模块重新通过现有上限,旧头的阻断项已在本次精确提交复验。批准范围涵盖这两个终端命令和兼容导出。

English verdict: APPROVE at 964e97e. Both commands surface the existing error in Markdown, healthy renderer output remains byte-identical, and extracting the upgrade-plan renderer resolves the prior module-budget failure.

This branch has not been deployed

No deployments
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.

3 participants