Skip to content

fix(update): keep repair JSON output parseable - #111117

Closed
arcabotai wants to merge 1 commit into
openclaw:mainfrom
arcabotai:fix/update-repair-json
Closed

arcabotai wants to merge 1 commit into
openclaw:mainfrom
arcabotai:fix/update-repair-json

Conversation

@arcabotai

@arcabotai arcabotai commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw update repair --json could emit Doctor, Clack, gateway-service, or terminal-reset bytes on stdout. Several reachable error paths also exited without emitting a JSON result. Automation parsing the complete stdout stream could therefore receive invalid or empty JSON.

Why This Change Was Made

JSON update finalization now owns the output contract at the public command boundary. Thrown finalization errors, invalid channels, invalid timeouts, pre-mutation failures, and final convergence failures emit one structured JSON result and route terminal restoration to stderr.

The embedded Doctor run receives a stderr-backed runtime and UI stream. Doctor scopes terminal notes to that stream across async work and forwards it through gateway-service stage, install, and restart operations. Human and non-JSON Doctor callers retain their existing runtime and stdout defaults.

The routing stays at the update finalizer, Doctor UI/note, and gateway-service lifecycle boundaries instead of intercepting process-global stdout.

User Impact

Automation can parse the complete stdout from openclaw update repair --json as one JSON value on success and on reachable command errors. Human update-repair behavior, Doctor repair decisions, gateway service policy, and fallback semantics are unchanged.

Evidence

Final exact candidate: c6e26379d6a68403bbd98025be91284436549155

Exact public-main parent: fe9e018045d4b332896d7d8160d1753eedc21fcd

Tree: 47102b914d97c5a8a04647969703652774449f85

Stable patch ID: 1352e1154b508f192a03ade11b2cebb744818b52

Validated with Node 24.15.0 and pnpm 11.2.2:

  • RED: the new public Commander-entrypoint matrix failed 3/3 before the command-boundary fix for thrown finalization, invalid channel, and invalid timeout
  • GREEN: command-entry and update-finalization matrix 8/8
  • GREEN: terminal-note, Doctor/Clack composition, gateway-service lifecycle, and shared command-runner matrix 55/55
  • final focused total 63/63
  • rich-TTY tests verify complete JSON parseability, one result, no terminal-reset bytes on stdout, and stderr reset routing
  • targeted oxfmt passed on all 12 changed paths
  • targeted update-CLI oxlint passed with 0 warnings and 0 errors
  • max-lines ratchet, conflict-marker, changelog-attribution, secret, dangerous-construct, and diff checks passed
  • final worktree clean

The exact semantic patch was replayed onto current public main with an unchanged stable patch ID and no changed-path overlap. Cad reran all focused and static gates on this final SHA.

Independent read-only review approved the exact final candidate with no patch-attributable blockers and judged it the best bounded fix.

The full build, full test suite, tsgo, and tsgolint were not run for this focused refresh; GitHub CI remains the broad verification gate.

AI-assisted: Meles prepared and exercised the candidate. Cad independently replayed it onto current main, reran the evidence gates, and verified the public lease before updating this PR.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: M labels Jul 19, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 19, 2026
@clawsweeper

clawsweeper Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This PR has been inactive for a while and still is not in a landable state.

Close as abandoned: the unchanged July branch is now merge-conflicted against a substantially redesigned update/Doctor path, lacks inspectable real-command proof, and is not a safe landing candidate.

So I’m closing this as inactive for now. If you pick the work back up, push a rebased branch with green checks and reopen (or open a fresh PR) and it will be reviewed again.

Review details

Best possible solution:

If the embedded Doctor-output defect still reproduces, open a new narrow PR from current main that extends the present root JSON and runDoctorHealthFlow ownership boundaries, with a redacted terminal proof.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: JSON update repair invokes Doctor, whose current notes and service operations can target stdout. No live command was run during this read-only review.

Is this the best way to solve the issue?

No: replaying this July implementation is not the best fix because current main centralizes JSON failures and has redesigned the Doctor entry flow; a fresh, narrow rebase is safer.

Security review:

Security review cleared: The diff adds no dependency, permission, workflow, credential, or supply-chain surface.

AGENTS.md: found and applied where relevant.

What I checked:

  • Stalled conflicted branch: The PR head is c6e2637 from 2026-07-19; GitHub context reports the PR as mergeableState dirty against current main. (src/flows/doctor-health.ts:18, c6e26379d6a6)
  • Current main owns JSON failures centrally: Current main’s update command rethrows JSON-mode errors to the root failure handler instead of emitting this branch’s local finalize envelope. (src/cli/update-cli.ts:32, e8044fdffef3)
  • Root handler emits structured JSON: Current main writes a canonical JSON failure at the CLI boundary and emits human diagnostics with console.error, so a rebased fix must use this newer ownership model. (src/index.ts:141, e8044fdffef3)
  • Doctor surface was substantially rewritten: Across the affected output paths, current main differs from this branch by 752 additions and 2,221 deletions; Doctor now enters through runDoctorHealthFlow, so the old wrapper cannot be adopted unchanged. (src/flows/doctor-health.ts:17, e8044fdffef3)
  • Current-main provenance: Blame attributes the current update JSON error-routing helper to 1bf4c1d, which is contained on main and was committed 2026-08-18T14:23:28+05:30. (src/cli/update-cli.ts:32, 1bf4c1d18c5f)
  • Release check: No release tag contains the current-main output-routing commit, so it is current-main-only provenance rather than a shipped fix. (1bf4c1d18c5f)

Likely related people:

  • ClawSweeper: Current-main blame assigns the update JSON error-routing helper to this author’s commit. (role: recent current-main output-path contributor; confidence: high; commits: 1bf4c1d18c5f; files: src/cli/update-cli.ts)

Codex review notes: model internal, reasoning high; reviewed against e8044fdffef3.

@arcabotai
arcabotai force-pushed the fix/update-repair-json branch from 86a9b67 to 256542f Compare July 19, 2026 02:05
@arcabotai

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@arcabotai

Copy link
Copy Markdown
Contributor Author

CI note: both exact-head attempts failed only in src/cli/acp-cli-exit.process.test.ts on child-process startup timeouts (acp --help, acp client --help, and spawnSync ... ETIMEDOUT). The latest shard passed 170/171 files and 3,123/3,127 tests; this PR changes no ACP paths. The contributor account cannot rerun upstream jobs (Must have admin rights to Repository), so the failed shard needs a maintainer rerun if required. CodeQL and the remaining selected lanes passed.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 19, 2026
@arcabotai
arcabotai force-pushed the fix/update-repair-json branch from 256542f to c6e2637 Compare July 19, 2026 16:29
@arcabotai

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant