Skip to content

fix(cli): make doctor --json imply read-only lint mode - #122662

Merged
steipete merged 2 commits into
mainfrom
steipete/doctor-json-implies-lint
Aug 12, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/doctor-json-implies-lint

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cloud supervisors and deployment scripts need one machine-readable preflight command. openclaw doctor --lint --json is that command, but bare openclaw doctor --json — the invocation every operator tries first — exits 2 with "doctor lint options require --lint. Use openclaw doctor --lint ...." (src/cli/program/register.maintenance.ts). The flag combination is unambiguous; rejecting it just to demand a second flag is pointless friction on the exact path headless bootstrap scripts take.

Why This Change Was Made

Third step of the cloud-container deployment track (#122477, #122530): make the obvious preflight invocation work.

  • Bare doctor --json now implies --lint: read-only checks, machine-readable JSON on stdout, non-interactive — byte-identical output to doctor --lint --json (proven black-box).
  • Existing machine modes are untouched: --lint --json, --post-upgrade --json, --state-sqlite/--session-sqlite combinations behave exactly as before (src/cli/doctor-output-mode.ts reserves machine output for them first).
  • Explicit conflict handling: doctor --json combined with --repair/--fix/--force fails fast with exit 2 and a clear message — repair is interactive and side-effectful; a JSON repair report is intentionally not defined.
  • --json help text and docs/cli/doctor.md now position doctor --json as the deployment preflight.

User Impact

  • openclaw doctor --json goes from an exit-2 error to the working read-only preflight.
  • No behavior change for any previously working invocation. No new flags, no config surface.

Evidence

  • Focused Vitest: 56 tests across 2 shards (regression: bare --json on pre-change code exits 2 — test fails pre-fix for the intended reason; conflict cases; machine-mode compatibility).
  • Black-box on the built CLI: bare --json and --lint --json outputs byte-identical; --json --repair/--fix/--force exit 2.
  • Core prod/test tsgo lanes, targeted oxlint, full pnpm build (3m29s), docs inventory, formatting, git diff --check: all pass.

Docs: https://docs.openclaw.ai/cli/doctor

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes labels Aug 12, 2026
@steipete
steipete marked this pull request as ready for review August 12, 2026 14:41
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 12, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 11:57 AM ET / 15:57 UTC.

ClawSweeper review

What this changes

The PR makes bare openclaw doctor --json run existing read-only lint checks with JSON output, while documenting that deployment-preflight shortcut.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This maintainer PR remains necessary: current main rejects bare Doctor JSON, while the updated branch routes it to the existing read-only lint owner and preserves the previously reviewed session-selector validation.

Priority: P2
Reviewed head: f22a53645217d84d68c4707a4bf78b0fc46eddc2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused, owner-boundary implementation with the prior selector regression addressed.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored CLI PR is exempt from the external-contributor proof gate; its body nevertheless records a built-CLI black-box comparison.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored CLI PR is exempt from the external-contributor proof gate; its body nevertheless records a built-CLI black-box comparison.
Evidence reviewed 7 items Current-main behavior: Current main treats bare --json as a lint-only option without --lint and exits before Doctor runs, establishing the reported operator friction.
Canonical owner-boundary repair: The PR’s parsed Commander options infer lint only when no established machine mode or session-only selector owns the invocation, keeping the behavior at Doctor command selection rather than downstream output handling.
Prior review finding covered: The updated test verifies that selector-only JSON invocations retain the corrective session-SQLite error and do not invoke lint.
Findings None None.
Security None None.

How this fits together

Doctor is OpenClaw’s CLI diagnostic and repair surface. Command parsing selects lint, repair, or SQLite maintenance behavior, then sends operator or automation-friendly output to stdout.

flowchart LR
  A[Operator or deployment script] --> B[Doctor CLI arguments]
  B --> C[Mode selection]
  C --> D[Read-only lint]
  C --> E[Repair or SQLite maintenance]
  D --> F[JSON findings]
  E --> G[Existing mode output]
Loading

Before merge

  • Resolve merge risk (P1) - Production code is net +11 lines for this behavior change; the added parsed-option predicate and explicit repair conflict are warranted at the Doctor command owner, and no smaller shared helper is evident because early output routing receives raw argv while the handler receives parsed options.
  • Complete next step (P2) - No repair lane is needed; the prior selector regression is addressed, so this PR can proceed through normal exact-head merge validation.
Agent review details

Security

None.

PR surface

Source +11, Tests +69, Docs +2. Total +82 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 26 15 +11
Tests 2 71 2 +69
Docs 1 7 5 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 104 22 +82

Review metrics

Metric Value Why it matters
Production versus test delta production +26/-15 (net +11), tests +71/-2 (net +69), docs +7/-5 (net +2) The small production increase implements mode selection and a side-effect conflict guard; the larger test delta covers output routing and command-handler behavior.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/cli/doctor-output-mode.ts, migration/backfill/repair: src/cli/machine-output-modes.test.ts, migration/backfill/repair: src/cli/program/register.maintenance.test.ts, migration/backfill/repair: src/cli/program/register.maintenance.ts, serialized state: src/cli/program/register.maintenance.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep a single parsed-option inference at the Doctor command owner, with the raw-argv resolver limited to preserving clean machine output for the selected mode.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep a single parsed-option inference at the Doctor command owner, with the raw-argv resolver limited to preserving clean machine output for the selected mode.

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

Yes, from source: current main’s Doctor action rejects bare --json before invoking lint, and the PR changes that exact parsed-option branch.

Is this the best way to solve the issue?

Yes. Reusing the established lint command at Doctor’s mode-selection boundary is preferable to creating a parallel preflight implementation or changing downstream output behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored CLI PR is exempt from the external-contributor proof gate; its body nevertheless records a built-CLI black-box comparison.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded CLI preflight improvement affecting automation ergonomics without an established outage or data-risk signal.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored CLI PR is exempt from the external-contributor proof gate; its body nevertheless records a built-CLI black-box comparison.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the Doctor machine-output predicate and command routing to this contributor’s recent merged work. (role: recent area contributor; confidence: high; commits: 2cb9a7564807; files: src/cli/doctor-output-mode.ts, src/cli/program/register.maintenance.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-12T15:14:48.218Z sha 6594d83 :: found issues before merge. :: [P2] Preserve validation for selector-only JSON invocations

@steipete

Copy link
Copy Markdown
Contributor Author

ClawSweeper P2 (selector-only JSON invocations) addressed in f22a536452 :

  • jsonImpliesLint now reuses the existing session-selector predicate, so doctor --json --session-sqlite-agent main (and store/all-agents/github-issue selector forms) reach the original corrective guard and exit 2 exactly as on main — no second validation flow, net delta stays small.
  • Regression test added for the --json selector form (fails on the pre-fix head); bare --json lint behavior and all existing machine modes unchanged (22 + 35 tests green).

@clawsweeper clawsweeper Bot added 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 12, 2026
@steipete
steipete merged commit 6093e34 into main Aug 12, 2026
129 checks passed
@steipete
steipete deleted the steipete/doctor-json-implies-lint branch August 12, 2026 16:04
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant