Skip to main content
Doctor rules are a plugin surface — any package can register a diagnostic-and-repair rule via the praisonai.doctor_contracts entry point and praisonai doctor picks it up alongside the built-in checks.

Quick Start

1

Write a rule

Implement DoctorContractProtocol: a rule_id, a collect_findings() that returns Findings, and an apply_fix() that returns a repaired config.
2

Register it via entry point

Expose the rule under praisonai.doctor_contracts in your pyproject.toml.
3

Run the doctor

Your rule now runs alongside the built-ins — collect findings, or preview and apply repairs.

How It Works

The registry loads built-in rules plus every rule discovered on the praisonai.doctor_contracts entry point, then runs each in isolation — a rule that raises is recorded in refused instead of aborting the whole run. A repair is a three-phase lifecycle: collect findings → apply fix → re-collect residual findings so callers can report “repair left N finding(s)”. In dry_run mode nothing is written; the plan’s config holds the proposed result.

Reference

Finding — one diagnostic result: RepairPlan — the result of plan_fixes(): Rule contract (DoctorContractProtocol):

Common Patterns

Preview before writing — plan_fixes defaults to dry_run=True:
Apply with a backup and re-validate:
Register a rule at runtime instead of an entry point:

Best Practices

It runs on every doctor invocation. Inspect the config only — no network calls, no writes.
Running the fix twice must produce the same config, and a follow-up collect_findings should return no findings for what you repaired.
message and fix_description show up verbatim in operator output — say what is wrong and what the fix does.
Prefix ids per package (my_channel_*, my_tool_*) so operators can filter and duplicate-id replacement is predictable.

Runtime Config Migration

The built-in cli_backend migration rule.

Gateway CLI

Run doctor and other gateway commands.

Gateway Config Migration

Migrate gateway configuration versions.

Doctor Optional Deps

Diagnose missing optional dependencies.