Skip to content

feat(doctor): check that the configured agent CLI actually starts - #822

Merged
coo1white merged 1 commit into
mainfrom
claude/trusting-wozniak-d0z17o-doctor-agent-probe
Oct 17, 2026
Merged

coo1white merged 1 commit into
mainfrom
claude/trusting-wozniak-d0z17o-doctor-agent-probe

Conversation

@coo1white

Copy link
Copy Markdown
Owner

Capability

cw doctor now catches an agent that is installed but cannot run. In the operator's 0.3.3 acceptance, doctor said all green while claude failed with Error: claude native binary not installed … reinstall without --ignore-scripts. Doctor now runs the vendor CLI once with --version, fails when it cannot start, and shows the CLI's own fix hint.

Implementation

  • New check agent-runs, right after agent / agent-binary:
    • pass: ✓ agent-runs: claude --version → 2.1.295 (Claude Code)
    • fail: ✗ agent-runs: claude --version exited 1: <first lines of its own output> + fix: line; doctor not ready, exit 1. Also timeout (timed out after 15s), could not start (ENOENT), stopped by signal.
    • custom command (e.g. a user wrapper script): ! agent-runs: not probed: custom command … — never executed.
    • no agent / HTTP endpoint only: no line; doctor output byte-identical to before.
    • --json: one more checks entry in the same shape.
  • Which CLI: versionProbe.clis in scripts/agents/builtin-templates.json (core holds no vendor list); agentProbeTarget() in src/shell/agent-config.ts.
  • Probe: spawnSync(cli, ["--version"]), shell:false, 15 s timeout (CW_DOCTOR_AGENT_PROBE_TIMEOUT_MS), cwd = repo, env from buildAgentChildEnv (provider keys, proxy, USER as in a real run); control chars stripped; output capped (pass 1 line/120 chars, fail 4 lines/300 chars); env values never printed.
  • buildChildEnv / buildAgentChildEnv accept Pick<ResolvedSandboxPolicy,"env"> (type-only), keeping doctor.modules at 42 for the perf ratchet.

POLA exception

  1. Intent: project/docs/intent/2026-10-16-release-gate-ci.md, "Operator decisions for 0.3.3": the question, the chosen option and the operator's full answer verbatim (2026-10-17), with a table of which bytes change.
  2. Man page: docs/doctor.7.md, "agent-runs (new in 0.3.3)".
  3. Version raise: in the 0.3.3 bump PR.

Tests

New test/doctor-agent-probe-smoke.mjs with stub CLIs on PATH: broken install (fail + hint + fix, JSON shape), working CLI (pass; probe env gets provider key, not unrelated vars; no value printed; CW_AGENT_COMMAND="claude -p" probed), hanging CLI (fails as timeout promptly), custom wrapper (not probed; marker proves it never ran), other checks unchanged and no entry when no agent. Fails on main, passes here. Byte compare vs main: human output differs only by the added line; --json identical once that entry is removed.

build, check, test:unit 144/144, test:gate 278/278, citation, growth, index, purity, lang, onramp check, release:check, perf counts: pass. Conformance 88/88 with a CI-like PATH (86/88 with the sandbox's PATH, the same 2 known failures as main).

Risk

Low-medium: a configured vendor CLI missing from PATH now fails doctor (before: a warn). Custom commands are never executed by doctor.


Generated by Claude Code

cw doctor said all green while the configured agent could not start
(claude: "native binary not installed ... reinstall without
--ignore-scripts / --omit=optional", exit 1). Doctor only checked that
the file was there.

New check agent-runs: when an agent command is set, doctor runs its
vendor CLI with --version (argv-style, shell:false, 15 s timeout, the
same child env as a real agent via buildAgentChildEnv, cwd = repo). It
reads only the exit code and the first lines of output.
- exit 0: ok, "<cli> --version → <first line>"
- non-zero / no start / timeout: fail (doctor not ready, exit 1), up to
  4 of the CLI's own lines (300 chars) and a fix line
- a custom command is never run: warn "not probed: custom command"

The vendor CLI per builtin wrapper is data in
scripts/agents/builtin-templates.json (versionProbe); core holds no
vendor table. buildChildEnv/buildAgentChildEnv now take only the env
part of a policy, so doctor needs no sandbox-profile load (module
ratchet unchanged).

POLA exception: operator's dated yes in intent
2026-10-16-release-gate-ci.md (0.3.3 part), docs/doctor.7.md says the
new check; the version raise comes in the 0.3.3 bump PR.

Test: test/doctor-agent-probe-smoke.mjs (fails on main's dist, passes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NpzNqRDJFpBt4cSyYjhbV3
@coo1white
coo1white marked this pull request as ready for review October 17, 2026 20:53
@coo1white
coo1white enabled auto-merge October 17, 2026 20:53
@coo1white
coo1white merged commit a80aabf into main Oct 17, 2026
9 checks passed
@coo1white
coo1white deleted the claude/trusting-wozniak-d0z17o-doctor-agent-probe branch October 17, 2026 20:58
coo1white pushed a commit that referenced this pull request Oct 17, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NpzNqRDJFpBt4cSyYjhbV3
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