Skip to content

perf: doctor summarized per-host output + ~9x faster (drop unread version-probe cost) - #416

Merged
getappz merged 2 commits into
masterfrom
task/429
Aug 9, 2026
Merged

perf: doctor summarized per-host output + ~9x faster (drop unread version-probe cost)#416
getappz merged 2 commits into
masterfrom
task/429

Conversation

@getappz

@getappz getappz commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • agentflare doctor's text output dumped every check (ok + missing) across every host, repeating the full describe boilerplate — now grouped per host (X/Y ok), with detail lines only for failures/stale rules, plus an overall pass count. --json output is unchanged.
  • default_hosts() called agent_registry::detect_all(), which spawns a --version subprocess per detected agent CLI — a value doctor never reads (only .id). On Windows, Node-wrapped CLIs (opencode, github-copilot-cli) cost 500ms+ per spawn, sequential: ~1.76s of doctor's ~3.6s runtime was output nobody looked at.
  • Added agent_registry::detect::detect_present() — PATH presence only, no subprocess — and switched default_hosts() to it. Fixed the identical latent bug in components.rs::detected_skill_agents() (its own comment already said it only needs agent IDs).
  • Memoized the doctor githooks/mise/leanctx checks (each spawns git/where) so they run once instead of once per host.

Result: agentflare doctor ~3.6s → ~365ms (~9-10x), output unchanged.

Test plan

  • cargo build --bin agentflare
  • cargo nextest run --workspace -E 'test(doctor::) or test(components::) or package(agentflare-agent-registry)' — 89/89 passed
  • Manual agentflare doctor / agentflare doctor --json run — output verified identical to before, just faster

Summary by CodeRabbit

  • New Features
    • Improved environment checks by detecting available command-line tools more efficiently.
    • Added cached checks for supported tools and integrations, reducing repeated detection overhead.
    • Enhanced the human-readable diagnostic report with host-level health markers, pass counts, failed checks, stale rules, and an overall summary.
  • Bug Fixes
    • Preserved the existing JSON diagnostic output while improving human-readable reporting.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The registry now detects CLI agents by binary presence on PATH. Component checks cache process-lifetime results. Skill-agent and doctor host discovery avoid version probing. The text doctor report now groups results by host and includes aggregate pass counts.

Changes

Presence Detection and Doctor Reporting

Layer / File(s) Summary
Add presence-only agent detection
crates/agent-registry/src/detect.rs, crates/agent-registry/src/lib.rs
Adds and re-exports detect_present, which returns IDs for CLI agents whose binaries exist on PATH.
Cache component and skill-agent checks
src/components.rs
Caches mise, lean-ctx, and git-hook checks for the process lifetime. Skill-agent discovery uses detect_present without version probing.
Update doctor host reporting
src/doctor.rs
Uses presence-only agent detection for default hosts. The text report shows per-host health details and aggregate pass counts while preserving JSON output.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Doctor
  participant DefaultHosts
  participant DetectPresent
  participant PATH
  Doctor->>DefaultHosts: Build default hosts
  DefaultHosts->>DetectPresent: Detect CLI agents
  DetectPresent->>PATH: Check agent binaries
  PATH-->>DetectPresent: Return present binaries
  DetectPresent-->>DefaultHosts: Return agent IDs
  DefaultHosts-->>Doctor: Return hosts for reporting
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the summarized doctor output and performance improvement, which are the main changes.
Description check ✅ Passed The description includes a detailed summary and test plan, but omits the optional Notes for reviewers section.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/429

Comment @coderabbitai help to get the list of available commands.

@getappz getappz changed the title doctor: summarized per-host output + ~9x faster (drop unread version-probe cost) perf: doctor summarized per-host output + ~9x faster (drop unread version-probe cost) Aug 9, 2026
getappz added 2 commits August 9, 2026 19:52
Group text output by host (X/Y ok), show detail lines only for
failing checks and stale rules, and add an overall pass count.
JSON output is unchanged.

Agentflare-Agent: claude-code_2-1-225_agent
Agentflare-Branch: task/429
Agentflare-Item: 429
default_hosts() called agent_registry::detect_all(), which spawns a
--version subprocess per detected agent to populate DetectedAgent.version
— doctor only ever read .id. On Windows, Node-wrapped CLI agents
(opencode, github-copilot-cli) each cost 500ms+ per --version spawn,
sequential across every detected host: ~1.76s of doctor's ~3.6s runtime
came from output nobody looked at.

Add agent_registry::detect::detect_present() — PATH presence only, no
subprocess — and switch default_hosts() to it. Fix the identical pattern
in components.rs::detected_skill_agents(), whose own comment already
said it only needs agent IDs. Also memoize the doctor githooks/mise/leanctx
checks (each spawns git/where) so they run once instead of once per host.

agentflare doctor: ~3.6s -> ~365ms, output unchanged.

Agentflare-Agent: claude-code_2-1-225_agent
Agentflare-Branch: task/429
Agentflare-Item: 429
@getappz
getappz merged commit dfbc8b6 into master Aug 9, 2026
16 checks passed
@getappz
getappz deleted the task/429 branch August 9, 2026 14:29
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.

1 participant