Skip to content

refactor(alertd): move the doctor subsystem into the alertd crate#438

Open
passcod wants to merge 2 commits into
mainfrom
phase1-doctor-into-alertd
Open

refactor(alertd): move the doctor subsystem into the alertd crate#438
passcod wants to merge 2 commits into
mainfrom
phase1-doctor-into-alertd

Conversation

@passcod
Copy link
Copy Markdown
Member

@passcod passcod commented May 30, 2026

🤖 Phase 1 of consolidating monitoring (TODO #10, plan in docs/plans/healthchecks-into-alertd.md). Behaviour-preserving refactor — no check logic changes.

The doctor/healthcheck subsystem was split across three crates: the Check type and checks in bestool-tamanu, the sweep orchestration + canopy posting in bestool, and the daemon framework in bestool-alertd. This moves the whole subsystem into bestool-alertd so the monitoring engine owns both the framework and the checks, with bestool-alertd now depending on bestool-tamanu for common Tamanu domain code (config, discovery, services, server-info DB queries). No dependency cycle — bestool-tamanu never depends on alertd.

  • bestool-tamanubestool-alertd: the entire doctor module (check, checks, checks/*, progress, server_info facts), mounted at crate::doctor.
  • bestoolbestool-alertd: SweepResult, perform_sweep, collect_server_facts, build_payload, overall_from_payload (now doctor/sweep.rs) and DoctorTask (now doctor/task.rs), with their tests. bestool keeps the tamanu doctor CLI, rendering, and daemon-fetch, calling bestool_alertd::doctor.
  • bestool-tamanu loses its doctor feature and the deps only it used (bestool-kopia, hickory-resolver, owo-colors, reqwest), which move to bestool-alertd.

The one mechanical change: perform_sweep now takes the running binary's version as a parameter instead of env!("CARGO_PKG_VERSION") (which would otherwise resolve to alertd's version once moved). Both callers pass bestool's version, so the wire payload is unchanged.

Subsequent phases migrate the YAML alerts to checks (in alertd), retire the YAML alert engine + standalone CLI, and review thresholds.

passcod and others added 2 commits May 30, 2026 17:24
Approved plan for TODO #10: invert the crate relationship so bestool-alertd
owns the doctor framework + checks (calling bestool-tamanu for common domain
code), migrate the 16 YAML alerts to checks (default FAIL, canopy owns
alerting), retire the YAML alert engine + standalone CLI, then review
thresholds across all checks.

Co-authored-by: Claude <noreply@anthropic.com>
Relocate the doctor framework, checks, sweep orchestration, and the
DoctorTask from bestool-tamanu and bestool into bestool-alertd. alertd
now owns the monitoring engine and depends on bestool-tamanu for common
Tamanu domain code; bestool's doctor CLI keeps only arg parsing,
rendering, and daemon-fetch, calling into bestool_alertd::doctor.

This is a behaviour-preserving relocation. The one functional fix:
perform_sweep and DoctorTask take the running binary's version as a
parameter, so the wire payload reports bestool's version rather than
alertd's (env!("CARGO_PKG_VERSION") would otherwise resolve to the
library crate).

Co-authored-by: Claude <noreply@anthropic.com>
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