daemon-health-checklisted
Install: claude install-skill standardbeagle/agnt
# Daemon Health Check & Doctor
Use this skill when implementing or modifying health check, reconciliation, or doctor functionality.
## Reconciliation Algorithm
The daemon's in-memory state is a cache. Reconciliation verifies it against OS truth and fixes mismatches.
### Step 1: Gather Expected State
- Parse `.agnt.kdl` for all projects with running scripts
- Build expected set: `{script → process, proxy → target, port → owner}`
### Step 2: Gather Actual State (OS Truth)
**Cross-platform requirement** — every probe must go through `internal/platform/`:
| Probe | Linux/macOS | Windows | WSL |
|-------|------------|---------|-----|
| PID alive | `kill(pid, 0)` or `/proc/<pid>` | `OpenProcess` | `kill(pid, 0)`, `cmd.exe` for Windows-spawned |
| Port owner | `ss -tlnp` / `lsof -i` | `netstat -ano` | `ss` for Linux, `netstat.exe` for Windows |
| Proxy health | TCP connect / HTTP GET | Same | Same |
### Step 3: Diff Expected vs Actual
| Finding | State update | Event |
|---------|-------------|-------|
| Process in daemon but PID dead | Mark Dead | Emit ScriptStopped |
| Port in use but not by our process | Flag rogue | Record PID in warning |
| Proxy in daemon but not responding | Mark unhealthy | Emit warning |
| Config expects proxy but none exists | Attempt fallback-port | Emit warning if no fallback |
| Process running, no URL detected, has fallback-port | Create proxy via fallback | Log proxy creation |
| Process producing error output | Mark Running With Errors | Sur