agora.doctor

One preflight: agora doctor.

Every entry point calls THIS module — no entry point reimplements a health check (integration-hardening Stage 4). Each check returns a structured CheckResult with a one-line red/green verdict and a fix hint; the report() helper prints them and yields a non-zero exit code on any red.

Library-clean: every check RECEIVES the endpoints/values it needs (composition roots inject them from Settings). This module never reads os.environ or Settings itself, so it stays off the config-import allowlist.

Functions

check_conduit(homeserver, user_id, password)

Conduit is reachable AND the system account can log in — if you use it.

check_ollama_models(base_url, required)

The active cast's models are present in /api/tags.

check_ollama_reachable(base_url)

Ollama daemon answers /api/version.

check_plantuml(url)

(--dev) The PlantUML render server answers.

check_vram(model, base_url, safety_margin_mib)

Enough free VRAM for model (existing vram.py fit math).

check_workspace_git(repo_root, work_dir)

We are inside a git work tree and the workspace root is creatable/writable.

format_line(r)

ollama_missing_models(tags, required)

Required model tags (name:tag) absent from an /api/tags payload.

preflight_or_die(results[, echo])

Report and raise SystemExit(1) on any red — for fail-fast entry points.

report(results[, echo])

Print each verdict; return 0 when all green, 1 when any check is red.

run_checks(*, ollama_base_url[, ...])

Run the standard preflight and return every result (order = display order).

skipped(name, reason)

A check that did not run, and says so.

Classes

CheckResult

One preflight check outcome.

class agora.doctor.CheckResult[source]

Bases: object

One preflight check outcome. hint is shown only when ok is False.

skipped is a THIRD state, deliberately not folded into ok: a check that never ran is not a check that passed. A run with the Matrix surface off should report [SKIP] conduit — reading [ OK ] conduit there would claim a homeserver was verified when none was contacted.

name: str
ok: bool
detail: str
hint: str = ''
skipped: bool = False
__init__(name, ok, detail, hint='', skipped=False)
agora.doctor.check_ollama_reachable(base_url)[source]

Ollama daemon answers /api/version.

agora.doctor.ollama_missing_models(tags, required)[source]

Required model tags (name:tag) absent from an /api/tags payload.

agora.doctor.check_ollama_models(base_url, required)[source]

The active cast’s models are present in /api/tags.

async agora.doctor.check_vram(model, base_url, safety_margin_mib)[source]

Enough free VRAM for model (existing vram.py fit math). An unavailable probe is GREEN — we never block a run on an unknown (matches vram.py policy).

async agora.doctor.check_conduit(homeserver, user_id, password)[source]

Conduit is reachable AND the system account can log in — if you use it.

An unset password is a SKIP, not a red. The Matrix surface is opt-in (C2): the core path is Python + Ollama and needs no homeserver, and you opt in by configuring one. “You never set it up” is not a failure to report; it is a check that does not apply.

This used to return red, which blocked every Tier-1 newcomer at the doctor gate on a service SETUP.md had just told them they did not need — the doc said “you don’t need Matrix”, the doctor said FAIL, and the doc also said “do not proceed until nothing is red”. Caught by the v0.1.0 front-door smoke on a fresh public clone; invisible on any box that happens to run Conduit.

agora.doctor.check_workspace_git(repo_root, work_dir)[source]

We are inside a git work tree and the workspace root is creatable/writable.

agora.doctor.check_plantuml(url)[source]

(–dev) The PlantUML render server answers. Dev-only: diagram tooling.

async agora.doctor.run_checks(*, ollama_base_url, required_models=(), vram_model, vram_safety_margin_mib, repo_root, work_dir, homeserver=None, matrix_user_id=None, matrix_password=None, dev=False, plantuml_url=None)[source]

Run the standard preflight and return every result (order = display order).

homeserver set ⇒ the Conduit reachable+login check runs. dev ⇒ the PlantUML check is appended.

agora.doctor.skipped(name, reason)[source]

A check that did not run, and says so.

Not a green: nothing was verified. Used where a dependency is genuinely absent from a run’s path (e.g. Conduit when the Matrix surface is off), so the report neither fails on it nor pretends it was checked.

agora.doctor.format_line(r)[source]
agora.doctor.report(results, echo=<built-in function print>)[source]

Print each verdict; return 0 when all green, 1 when any check is red.

agora.doctor.preflight_or_die(results, echo=<built-in function print>)[source]

Report and raise SystemExit(1) on any red — for fail-fast entry points.