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 thepraisonai.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:
Best Practices
Keep collect_findings fast and side-effect-free
Keep collect_findings fast and side-effect-free
It runs on every doctor invocation. Inspect the config only — no network calls, no writes.
Make apply_fix idempotent and re-checkable
Make apply_fix idempotent and re-checkable
Running the fix twice must produce the same config, and a follow-up
collect_findings should return no findings for what you repaired.Return actionable message strings
Return actionable message strings
message and fix_description show up verbatim in operator output — say what is wrong and what the fix does.Use a stable rule_id prefix
Use a stable rule_id prefix
Prefix ids per package (
my_channel_*, my_tool_*) so operators can filter and duplicate-id replacement is predictable.Related
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.

