Skip to content

feat(cli): add proofline doctor diagnostics command (--json, --offline) - #99

Open
arifrhm wants to merge 1 commit into
prooflinedev:mainfrom
arifrhm:feat/doctor-command
Open

arifrhm wants to merge 1 commit into
prooflinedev:mainfrom
arifrhm:feat/doctor-command

Conversation

@arifrhm

@arifrhm arifrhm commented Nov 26, 2026

Copy link
Copy Markdown

Summary

Adds proofline doctor (--json, --offline, --remote <NAME>) to diagnose the local environment, TLS configuration, credentials, server reachability, Git repository/remote resolution, Git hooks, and coding-agent MCP registrations in a single structured pass.

Who this helps

  • Developers & platform engineers onboarding onto Proofline behind corporate TLS-inspecting proxies (--ca-cert / PROOFLINE_CA_CERT), headless Linux environments (D-Bus user session vs PROOFLINE_TOKEN), or custom Git remotes (--remote).
  • Coding agents & CI scripts that need a deterministic, machine-readable (--json) pre-check with actionable remediation steps and zero secret exposure before running reviews, hooks, or MCP tools.

What was decided

  • Early dispatch before fatal setup: Command::Doctor is handled in lib::run before tls::trust and Origin::parse so an unreadable --ca-cert or invalid --base-url is reported as a structured fail check (including valid --json output) rather than aborting before diagnostics run.
  • Zero secret exposure: PROOFLINE_TOKEN and OS keychain secrets stay wrapped in secrecy::SecretString and are never serialized into text or JSON output; only credential source, organization UUID, scopes, and expiration status are reported.
  • Reuse existing subsystems without duplicating logic: Added small read-only inspection helpers (agent::inspect_clients with a 1 MiB file-size guard and hooks::inspect_hooks) and reused Origin::parse, tls::read, credentials::load, git::config, git::full_name, and text::one_line sanitization.
  • Exit contract: Exits 0 when all checks pass/warn/skip (ok: true), and exits 1 (Verdict::Blocked) when any check fails (ok: false).

Checks included

  1. origin — Validates --base-url / PROOFLINE_BASE_URL via Origin::parse.
  2. tls_ca_cert — Validates bundled roots or --ca-cert / PROOFLINE_CA_CERT PEM bundle.
  3. credentials — Inspects PROOFLINE_TOKEN (+ --org / PROOFLINE_ORGANIZATION_ID) or OS keychain credential & expiration.
  4. server_auth — Probes /api/v1/... with the loaded token (skipped under --offline or failed prerequisites).
  5. git_repository — Checks git availability and whether --remote resolves to a GitHub owner/name.
  6. git_hooks — Checks pre-commit and pre-push for Proofline hook markers.
  7. mcp_clients — Inspects Claude Code, Codex, Cursor, Gemini CLI, and Kiro user configs for a Proofline MCP entry.

How it was tested

  • cargo fmt --check — passed.
  • cargo clippy --locked --all-targets -- -D warnings — passed with 0 warnings.
  • cargo test --locked doctor — passed:
    • 6 unit tests in src/doctor.rs (origin, tls_ca_cert, credentials secret redaction & org warning, mcp_clients detection, git_hooks detection, DoctorReport counts/ok invariant).
    • 2 integration tests in tests/doctor.rs (--offline --json end-to-end binary execution with secret redaction assertion, and nonzero exit on invalid --base-url + missing --ca-cert).
  • cargo test --locked --lib — 73/73 unit tests passed.

This branch has not been deployed

No deployments
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