Skip to content

impl(fleet): machine watchdog — per-machine health reporting for amd-6 (#2179 §1.5) - #12758

Merged
dezren39 merged 1 commit into
mainfrom
felix/2179-watchdog-reporting
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
felix/2179-watchdog-reporting

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Watchdog per-machine reporting for #2179 (§1.5) — remainder 1 from the S1 record (PR #12717). Unmerged for review.

What lands

scripts/fleet-machine-watchdog.py — the writer §3 names for the registry health cache. Per run it probes the machine and rewrites only the health block of its registry record (surgical text replacement; every other byte preserved; the result must pass the validator before it is kept, else the original bytes stand). Transports: fleet-shell (default — the sandbox seat probes amd-6 via fleet shell) and local (on-host). Strict #3352 argument contract (undeclared flag / missing registry → exit 2).

The §1.5 minimum record, each check ok/failed/unknown with a reason when it could not run:

  • reachable — SSH (probe transport answering on-host) + OpenCode server responding at the record's declared endpoint (any HTTP answer; the API's auth wall is not a health failure);
  • load_headroom — load15 vs declared cpu_cores (fail above 1.0/core);
  • disk_headroom — free space on the worktree (home) volume (fail below 10% free);
  • sessions — server session count via the on-host OpenChamber attach API. The API pages over history, so listed/active-within-cadence are recorded as facts beside the declared cap; the cap is a placement limit (§1.3), not gated on, because activity-within-a-cadence is not concurrency;
  • last_queue_job — newest done task in the queue store (queue + worker recorded; informational, never a gate — a queue may be idle). amd-6 is the only execution node, so the queue-wide newest completion is its last successful job.

Status derivation (in the script docstring): transport failure → unknown (a broken probe path is not a dead machine); reachable ran and failed → unreachable; a gating check failed → degraded; a gating check unknown → unknown; all gating checks ok → healthy. last_seen is the last actual sighting — a run that cannot reach the machine does not advance it, so staleness accrues and the reader rule (placement_view: stale > 2 cadences → left) demotes without touching declared state.

Validator earning rules (validate-fleet-machine-registry.py): a status other than unknown, or any non-null last_seen, now requires the full checks record (reported_at + all five checks, each with a valid state). Fail-before: the pristine validator accepted a bare hand-written status: healthy with no checks and no last_seen — a fabricated pass. Pass-after: it rejects that, partial records, and unparseable timestamps, and accepts watchdog-written records including an earned unreachable.

First real record (written by the watchdog, in this PR)

amd-6 is degraded: disk headroom failed — 197 GiB free of 3,371 GiB (5.8%) on the worktree volume. Reachable ok (SSH + server HTTP 200), load ok (0.46/core), sessions ok (50 listed on the recent page, 17 active within cadence, cap 12 recorded), last queue job ok (task 20095, repo-health-code-pilot, repo-worker-code, completed 2026-11-23T01:20:25Z). Declared fields untouched — amd-6 was already active via §2; no machine is activated by this change.

Evidence

  • scripts/test_fleet_machine_watchdog.py: 13/13 (status derivation incl. unreachable-keeps-last_seen and transport-failure-is-unknown, staleness/placement view, surgical-write isolation: prefix bytes identical, declared fields unchanged, result validates).
  • scripts/test_validate_fleet_machine_registry.py: 18/18 (10 prior + 8 earning-rule tests).
  • Live runs from the sandbox seat: dry-run and the real write both exit 0; validate-fleet-machine-registry.py doc/fleet-machine-registry.yaml → ok: amd-6 (active). The real run also caught and fixed a bug en route: a dropped Turso connection crashed the queue probe instead of reporting unknown — network errors now yield the reason, per the earning rule.
  • No new dependencies (PyYAML is already the validator's).

Not in this PR

  • No schedule created: the cadence is 15 min (the fleet watchdog's), but wiring the recurring seat run (a Muse cron on the sandbox seat invoking this script and landing the refreshed block) is seat infrastructure, left as the named follow-up on Machine pool: onboard additional machines as fleet job nodes and redesign placement around a pool #2179 — so doc/fleet-schedule-registry.md is unchanged rather than carrying a row for a job that does not exist yet.
  • Placement framework v1.1 machine dimension (remainder 2) and the Osseo physical pass (remainder 3) are untouched.

Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

#2179 §1.5)

scripts/fleet-machine-watchdog.py is the writer §3 names for the
registry health cache: it probes each machine (fleet-shell transport
from the sandbox seat, or local on-host), computes the §1.5 minimum
record — reachable (SSH + OpenCode server), load headroom vs declared
cores, disk headroom on the worktree volume, server session count via
the on-host OpenChamber attach API, last successful queue job from
the queue store — and rewrites ONLY the health block, preserving every
other byte. Health is earned: each check is ok/failed/unknown with a
reason, healthy requires every gating check ok, and last_seen (the
last actual sighting) never advances on a run that could not reach
the machine, so staleness accrues and readers demote per §1.5/§4.

The validator now enforces the earning rules: a non-unknown status or
a non-null last_seen without the full checks record is a fabricated
pass and fails (fail-before: pristine validator accepted a bare
hand-written status: healthy).

First real record, written by the watchdog itself: amd-6 is degraded
— disk headroom failed (197 GiB free of 3,371 GiB, 5.8%); reachable,
load (0.46/core), sessions, and last queue job (task 20095, done
2026-11-23T01:20:25Z) all ok. Declared state untouched: amd-6 was
already active via §2; no machine is activated by this change.

Tests: 13 watchdog (status derivation, staleness/placement view,
surgical-write isolation) + 8 new validator earning tests; 31/31 pass.
No new dependencies (PyYAML, already the validator's).

Cadence is 15 minutes (the fleet watchdog's); the recurring seat run
is not wired by this PR — see #2179 note. No schedule is created, so
doc/fleet-schedule-registry.md is unchanged.
@dezren39
dezren39 requested a review from a team as a code owner November 23, 2026 01:31
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2d3f4f43-f0bf-4f97-ac4d-ab2fedd9cbd4
Commits

Reviewing files that changed from the base of the PR and between 2a064b4 and e9e8ae2.

Files selected for processing: 5

  • doc/fleet-machine-registry.yaml
  • scripts/fleet-machine-watchdog.py
  • scripts/test_fleet_machine_watchdog.py
  • scripts/test_validate_fleet_machine_registry.py
  • scripts/validate-fleet-machine-registry.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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