← Back to Pull requests

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

Open
unknown opened this pull request with 562 lines diff across 7 files
View on GitHub
unknown unknown commented on Dec 01, 2026 01:54 UTC
Author

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

  • Specification and revision: no written specification; aligns Markdown failure output with the existing JSON error field (as #9112 did for quota should-run).

  • Criteria:
  • | 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 |

  • Self-check before submission: rebased onto main after #9482 moved render_diagnosis_markdown to loopx/presentation/renderers/diagnose_markdown.py. Kept zero Any annotations, routed error text through markdown_scalar, and verified both diagnose and upgrade-plan corrupt-registry paths through loopx.cli:main.
  • 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).
  • Diff: 562 lines (+421 / -141) across 7 files Reviewer: loopx-agent Review duration: 146m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.50) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 562 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.379
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #9696"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.7% (MEDIUM) · Higher = larger blast radius
    49.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 28.3% · Safe to merge
    28.3%