[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M757WHZWAVZV9MY6V5DR89M4":3,"skill-same:01M757WHZWAVZV9MY6V5DR89M4":110},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":32,"repositoryHtmlUrl":33,"repositoryHomepageUrl":34,"ownerHtmlUrl":35,"ownerBlogUrl":6,"ownerDescription":36,"updatedAt":37,"install":38,"resources":51},"01M757WHZWAVZV9MY6V5DR89M4","agent-health-monitoring",null,"Cross-server agent health monitoring using binary status vectors — deploy health endpoints on each agent, poll from orchestrator, alert on state transitions.","lukemcqueen\u002Fsteadfaste-fleet","lukemcqueen","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F405240?v=4","01M757MHPAGRXTJAT46SKZP98R","Luke McQueen","01M757MHPZ573KP8DT9GB8SBQ7",4,"MIT","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: agent-health-monitoring\ndescription: Cross-server agent health monitoring using binary status vectors — deploy health endpoints on each agent, poll from orchestrator, alert on state transitions.\nversion: 3.5.0\nauthor: Steadfaste Fleet\nplatforms: [macos, linux]\n---\n\n# Agent Health Monitoring\n\n## ⚠️ Mandatory Health Verification Protocol — FOLLOW EVERY TIME\n\nBefore claiming any agent is healthy or reporting health status, execute these steps **in order**. Localhost checks are NOT sufficient — external reachability is the only valid measure.\n\n### Step 1: Identify the external health URL\n\nFor the current agent (Moses), read `FLEET_HEALTH_URL` from `.env`:\n```bash\ngrep FLEET_HEALTH_URL ~\u002Fsteadfaste-fleet\u002F.env\n# → https:\u002F\u002Fexample.com:13007\u002Fhealth\n```\n\nFor remote agents in the registry, read `health_url` from `agent-registry.json` (merged with local overrides from `~\u002F.hermes\u002Fagent-registry.local.json`). The public registry's `http:\u002F\u002F127.0.0.1:PORT\u002Fhealth` defaults are LOCALHOST PLACEHOLDERS — never trust them as the external truth.\n\n### Step 2: Probe the external URL\n\n```bash\ncurl -sS --max-time 10 \u003CEXTERNAL_HEALTH_URL>\n```\n\nThis returns the full vector (e.g. `{\"v\":[1,1,-1,1,1,1,1,1,1],\"h\":\"m\",\"t\":...}`). Use the external response. Discard any localhost-only curl you ran earlier — it does not count.\n\n### Step 3: Decode every non-1 element\n\nFor each `-1` in the vector:\n- **Index 0** → resources (CPU\u002Fmemory\u002Fdisk)\n- **Index 1** → services (nginx, ollama, mycortex, etc.)\n- **Index 2** → no_errored_crons — check `cronjob action='list'` for `last_status != \"ok\"`\n- **Index 3** → no_stale_crons\n- **Index 4** → nginx\n- **Index 5** → ollama\n- **Index 6** → mycortex\n- **Index 7** → disk\n- **Index 8** → mycortex_sources\n\n### Step 4: Diagnose each issue\n\nFor errored crons (index 2 = -1): find the failing cron by checking the cron list for errors, then read that cron's output from `~\u002F.hermes\u002Fcron\u002Foutput\u002F\u003Cjob_id>\u002Flatest.md`.\n\n### Step 5: Report honestly\n\nState: \"External URL: \u003Curl> → vector, [x] of [9] green, [n] issues: \u003Clist>\". Never claim \"healthy\" or \"green\" unless the external URL returned all 1s.\n\n> **Common failure:** You curl localhost (127.0.0.1:8905 or 127.0.0.1:13007), it returns all-1s, and you claim healthy. Meanwhile the external URL returns -1 at index 2 because a cron errored. Localhost bypasses nginx TLS and may serve cached\u002Fstale data. The external URL is the source of truth.\n\n---\n\n> **Principle: Verify before building.** When diagnosing fleet health issues, first verify the existing registry covers all known agents. The `agent-registry.json` + `agent-registry.local.json` should list every agent. Do not build speculative registration or discovery infrastructure when the registry is already populated. If an agent is unreachable, check whether it's a server (HTTP-polled) or client-only (inbox-pushed) agent before building new communication channels.\n\nMonitor agent servers via a **binary status vector** — a compact JSON payload\nwith deliberately **no authentication** because the data is minimal\n(just `1`=up, `-1`=down, `0`=n\u002Fa per service). The vector contains no secrets,\nno PII, no version info — just eight bytes of binary flags.\n\n> **Key design decision:** Health endpoints run on plain HTTP with no auth.\n> Putting a binary status vector behind Basic Auth adds latency and token overhead\n> for zero security value. The agent inbox (which carries actual messages) still\n> uses per-agent credentials. See PITFALLS below.\n\n## ⚠️ Two Vector Formats in Play\n\nThere is **one** deployed health vector format in the ecosystem. Earlier\ndocumentation described a FastAPI `health-server.py` variant — that file was\n**removed from the repo** (July 2026, commit `42fb8374`, \"remove redundant\nFastAPI health-server\") and `health-vector.py` running via `health-vector.service`\nis the **only** deployed server. Do not look for `health-server.py` — it does\nnot exist in the repo and is not deployed anywhere in the fleet.\n\n| Format | Source | Vector length | Indices mean | Used by |\n|--------|--------|---------------|--------------|---------|\n| **Compact health** | `health-vector.py` → `CHECK_FUNCTIONS` \u002F `get_vector()` | **9 elements** | Aggregated check results (see below) | Every deployed health endpoint (`:13007\u002Fhealth`, `:12007\u002Fhealth`, `:14007\u002Fhealth` — nginx proxy to `:8905`) |\n\n### Compact Health Format (DEPLOYED) — 9-element `v` array\n\nThis is the format returned by every deployed health endpoint\n(`health-vector.py` via `health-vector.service` — see\n`references\u002Fhealth-vector-schema-migration.md` for the 8→9 element migration).\n\n```python\nv = [\n    1 if resources_ok else -1,         # [0] resources — CPU\u002Fmemory\u002Fdisk within limits\n    1 if services_ok else -1,          # [1] services — all critical services are running\n    1 if no_errored else -1,           # [2] no errored crons — all cron jobs ran without error\n                                       #     ⚠️ See references\u002Fwatchdog-vs-crash-semantics.md\n                                       #     \"errored\" includes watchdog scripts that correctly\n                                       #     exited non-zero on detection — not just crashes\n    1 if no_stale else -1,             # [3] no stale crons — schedule-aware (2x expected interval, not hardcoded 24h)\n    1 if nginx_ok else -1,             # [4] nginx — pgrep nginx\n    1 if ollama_ok else -1,            # [5] ollama — pgrep ollama\n    1 if mycortex_ok else -1,            # [6] mycortex — pgrep mycortex\n    1 if disk_ok else -1,              # [7] disk — disk usage \u003C 80%\n    1 if mycortex_sources_ok else -1,    # [8] mycortex sources — all mycortex sources healthy\n]\n```\n\n**Semantics:** `1` = healthy, `-1` = unhealthy\u002Fwarning, `0` = not applicable \u002F not installed on this system.\n\n| Value | Meaning |\n|-------|---------|\n| `1` | Service is running or condition is satisfied |\n| `0` | Service is **not installed** on this agent (nginx on a macOS dev box, mycortex on a minion, etc.) |\n| `-1` | Service IS installed but **not running**, or condition is violated |\n\nThe `0` value is supported by `health-vector.py`'s check functions. Each\nper-service check now uses `shutil.which()` to detect if the binary exists\nbefore probing for the running process — returns `0` if not found.\n\n`health-server.py` (FastAPI variant, **removed in commit `42fb8374`**) still only\nreturned `1` or `-1` since it aggregated checks per-machine where all services\nshould be present. Only `health-vector.py` is deployed — see the retired-server\nnote in the diagnostics section below.\n\n### A capability check reports on the capability's OWN tool — never on a copy of its knowledge\n\nWhen adding a check for something the fleet ships per-object — harnesses, skills, provider\nintegrations, MCP servers — hold the check to the same split the `0` semantics above already\nencode:\n\n- **Knowledge of what each object needs lives in that tool's own registry, not in the check.**\n  A second copy inside the check goes stale the moment an object is added, and the check then\n  reports on an old world. Iterate the registry and report ONE line per declared object.\n- **Drive the tool's own CLI to decide the verdict**, rather than re-implementing the decision\n  in the check. One implementation of \"is this capability wired correctly\" is the only way the\n  check and the CLI cannot disagree.\n- **Read the registry THROUGH that CLI, not by importing a parser.** The check may run under a\n  bare `python3` (a deploy path often does), and an `import yaml`-shaped read then downgrades\n  every object to could-not-verify on a healthy host. Two extra rules: a registry the CLI cannot\n  read is reported as could-not-verify with the CLI's own rc, and a missing interpreter is exit\n  `3` — never `1`, which reads as \"the capability is broken\". Resolver recipe: `shell-scripting`\n  → \"Resolving an Interpreter by CAPABILITY\".\n- **Keep the four outcomes distinct: PASS \u002F WARN \u002F SKIP \u002F could-not-verify.** Not-installed is a\n  SKIP (the `0` rule above) and must not be counted as a fault; \"declared unsupported\" is a SKIP\n  carrying the registry's OWN reason, not the generic not-installed wording — the two read\n  differently to whoever has to act on them.\n\n### Legacy Health Vector Format (NOT DEPLOYED) — 8-element `v` array\n\nFrom the old `health-vector.py` template. Not actively deployed but may be\nreferenced in older documentation or templates.\n\n| Index | Service | Code |\n|-------|---------|------|\n| 0 | nginx | 1=up, -1=down, 0=n\u002Fa |\n| 1 | Ollama | same |\n| 2 | mycortex | same |\n| 3 | Fleet Dashboard | same |\n| 4 | Langfuse web | same |\n| 5 | Langfuse worker | same |\n| 6 | Docker | same |\n| 7 | Hermes Gateway | same |\n\n### Critical: Never assume index meaning across formats\n\nIf you see vector index 3 = -1, it means:\n- **In compact format (DEPLOYED):** Stale cron jobs (no_stale = False)\n- **In legacy format:** Fleet Dashboard is down\n\n**Always check which format the endpoint serves** before diagnosing.\nSee `references\u002Fcompact-health-vector-format.md` for detailed source\ncode reference.\n\n## Architecture\n\n```\n                        ┌──────────────────────┐\n                        │  Agent Registry v3+   │\n                        │  health_method per     │\n                        │  agent in JSON         │\n                        └───────┬──────────────┘\n                                │\n                                ▼\n┌──────────────────────────────────────────────────────┐\n│  Moses (orchestrator)                                 │\n│  orch-health-report.py (hourly) \u002F                     │\n│  orch-fleet-watchdog.py (5 min)                       │\n│                                                       │\n│  for each agent:                                      │\n│    if health_method == \"http\":  ──→ HTTP GET :PORT    │\n│    if health_method == \"inbox\": ──→ read inbox_       │\n│                                     health-check      │\n│                                     state file        │\n│                                                       │\n│  State tracked by fingerprint vector                  │\n│  Alerts only on state transitions                     │\n└─────────────────────────┬────────────────────────────┘\n                          │\n            ┌─────────────┼─────────────────┐\n            ▼             ▼                   ▼\n┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐\n│  Gisu (server)   │ │  Joseph (server) │ │  Titus (macOS)   │\n│  health-vector.py│ │  health-vector.py│ │  NO inbound      │\n│  --serve :13007  │ │  --serve :12007  │ │                  │\n│  HTTP-polled     │ │  HTTP-polled     │ │  health-vec-push │\n│                  │ │                  │ │  → PGMQ bus      │\n└──────────────────┘ └──────────────────┘ │  inbox_health_   │\n                                          │  check queue     │\n                                          │  every 10 min    │\n                                          │  (launchd plist) │\n                                          └──────────────────┘\n```\n\n- **Server agents** (health_method=\"http\"): Moses polls their health vector server directly on the agent's assigned port. Each agent has its own port (see table below).\n- **Client-only agents** (health_method=\"inbox\"): Push their health vector to the PGMQ bus queue `inbox_health_check` (`health-vector-push.sh`, POST `\u002Fapi\u002Fpgmq\u002Fsend`). The `orch-clean-health-queue` cron (every 10 min) drains the queue and persists each agent's latest vector to `~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json`; `orch-health-report.py` reads that file.\n\n### ⚠️ Two Orthogonal Monitoring Systems\n\nThe fleet runs **two independent monitoring systems** that measure different things. They can disagree — bus-offline does not mean health-down, and health-green does not mean bus-active. Understanding the distinction prevents confusion:\n\n| System | Script | What it measures | \"Offline\" means | Feed |\n|--------|--------|-----------------|-----------------|------|\n| **HTTP Health Vectors** | `orch-health-report.py`, `orch-fleet-watchdog.py` | Service-level health (resources, services, crons, nginx, ollama, mycortex, disk) | Service is down or degraded | `GET \u002Fhealth` endpoint per agent |\n| **Bus Liveness** | `orch-fleet-watchdog.py` | Agent bus activity — last time the agent produced a PGMQ audit log event | Agent hasn't touched the bus recently (may be sleeping, idle, or disconnected) | `bus.audit_log` in Postgres |\n\n**When they disagree:**\n- **Bus shows 🌙 offline but health is 🟢**: The agent is running and serving but hasn't processed any bus messages recently. Common for agents that only do local cron work or whose bus-processing crons run on a sparse schedule.\n- **Health shows 🔴 but bus shows ✅**: An agent has a service issue but can still post to the bus. The bus liveness check alone is insufficient for true health assessment.\n\n**Diagnosis procedure when an agent appears offline:**\n1. Check the bus audit log: `docker exec mycortex-postgres psql -U mycortex -d mycortex -t -c \"SELECT created_at, action FROM bus.audit_log WHERE agent_name='\u003Cname>' ORDER BY created_at DESC LIMIT 5;\"`\n2. Check the HTTP health endpoint via external URL (see Verification Protocol above)\n3. If bus shows offline but external URL shows healthy → agent is alive, just idle on the bus\n4. If both show offline → real problem\n\n❌ **Do this first:** Check the EXTERNAL HTTPS URL (Steps 1-2 of Verification Protocol), not the bus audit log. The bus is a secondary indicator — health is the primary one.\n\n### Per-Agent Port Allocation\n\nEach server agent gets a dedicated **external** port for nginx SSL termination.\nThe health-vector process binds to **127.0.0.1** (loopback) on the internal port\n(typically 8905) — nginx proxies `\u003Cexternal-port>\u002Fhealth` → `127.0.0.1:\u003Cinternal-port>`.\nThis prevents port conflicts and ensures TLS is handled at the proxy layer.\n\nExternal port mapping (agents poll the nginx SSL port):\n\n| Agent | External port (nginx SSL) | Internal port (health-vector) | Method |\n|-------|--------------------------|-------------------------------|--------|\n| Moses | 13007 | 8905 | HTTP poll via nginx proxy |\n| Gisu | 13007 | 8905 | HTTP poll via nginx proxy |\n| Kustos | 13007 | 8905 | HTTP poll via nginx proxy |\n| Joseph | 12007 | 8905 | HTTP poll via nginx proxy |\n| Esther | 14007 | 8905 | HTTP poll via nginx proxy |\n| Titus | — | — | Inbox push |\n\n> **PII note:** Actual domains are set via local override (`~\u002F.hermes\u002Fagent-registry.local.json`),\n> not committed to the public repo. See PITFALLS > Public repo PII.\n\n### Agent Registry health_method\n\nEach agent in `agent-registry.json` declares how Moses should poll it:\n\n```json\n\"moses\": {\n  \"health_method\": \"http\",\n  \"health_url\": \"http:\u002F\u002F127.0.0.1:13007\u002Fhealth\"\n},\n\"gisu\": {\n  \"health_method\": \"http\",\n  \"health_url\": \"https:\u002F\u002F\u003Cgisu-domain>:13007\u002Fhealth\"\n},\n\"titus\": {\n  \"health_method\": \"inbox\"\n}\n```\n\n**For PII safety**, the public repo stores port hints in description fields only.\nActual `health_url` values are configured via a local override file (see below).\n\n## Components\n\n### 1. `health-vector.py` — Agent-side health probe\n\nInstalled on every agent server. Two modes:\n\n```bash\n# Standalone (JSON to stdout)\npython3 health-vector.py\n\n# HTTP server (listens on \u003CPORT>)\npython3 health-vector.py --serve \u003CPORT>\n\n# Human-readable check\npython3 health-vector.py --check\n```\n\n**Output format:**\n```json\n{\"v\": [1, 1, 1, 1, 1, 1, 1, 1], \"h\": \"m\", \"t\": 1700000000}\n```\n\n**Hostname convention:** The `h` field should be a **single character** per agent\nfor compact display in health reports:\n| Agent | `h` value |\n|-------|-----------|\n| Moses | `\"m\"` |\n| Gisu | `\"g\"` |\n| Kustos | `\"k\"` |\n| Joseph | `\"j\"` |\n| Esther | `\"e\"` |\n| Titus | `\"t\"` |\n\nSet by `HEALTH_HOSTNAME` env var, falling back to the hostname's first character\n(`moses` → `m`, `gisu` → `g`, `titus` → `t`). Override per-machine if the\nhostname doesn't match the table:\n```python\nHOSTNAME = os.environ.get(\"HEALTH_HOSTNAME\") or os.uname().nodename.split(\".\")[0][:1].lower() or \"m\"\n```\nRun the service with `Environment=HEALTH_HOSTNAME=m` in the unit if the hostname\never diverges from the convention.\n\n**Bind address:** The server binds to **127.0.0.1** (loopback) when behind an\nnginx proxy to avoid port conflicts. nginx terminates TLS on `0.0.0.0`.\n```python\nserver = HTTPServer((\"127.0.0.1\", port), HealthHandler)  # not \"0.0.0.0\"\n```\n\nEach check function probes for the service:\n- **nginx**: `pgrep -x nginx`\n- **Ollama**: systemd\u002Flaunchd service, fallback to `pgrep ollama`\n- **mycortex**: systemd\u002Flaunchd service, fallback to `pgrep mycortex`\n- **Fleet Dashboard**: `curl http:\u002F\u002F127.0.0.1:8901\u002Fapi\u002Fhealth`\n- **Langfuse web\u002Fworker**: Docker container check\n- **Docker**: `dockerd` process or `\u002Fvar\u002Frun\u002Fdocker.sock`\n- **Hermes Gateway**: `pgrep -f \"gateway run\"`\n\n### `health-server.py` — RETIRED (removed commit `42fb8374`)\n\n> ⚠️ **This server is retired.** The FastAPI `health-server.py` was removed from\n> the repo in July 2026 (commit `42fb8374`); `health-vector.py` via\n> `health-vector.service` is the **only** deployed health server. The log-format\n> reference below is kept for reading HISTORICAL journal logs from before the\n> removal — it does not describe the current `health-vector.py` (which logs\n> minimally). Diagnostic procedure for the CURRENT server: check the\n> `health-vector.service` unit and its journal instead\n> (`systemctl --user status health-vector.service`,\n> `journalctl --user -u health-vector.service`).\n\nAs of July 2026, the retired `health-server.py` had structured logging with per-request timing.\nEvery request writes a line to stdout (captured by systemd journal) showing each\ncheck's duration:\n\n```\n2026-07-02T08:57:13.625 [INFO] COMPACT — m total=20.1s resources=0.0s services=0.1s crons=0.0s mycortex=20.0s\n2026-07-02T08:57:13.625 [WARNING] SLOW COMPACT HEALTH — m took 20.1s\n```\n\n**Log line reference:**\n\n| Prefix | Level | When | Example |\n|--------|-------|------|---------|\n| `STARTING` | INFO | Process starts | `server=moses agent=m port=8905 os=linux\u002F6.14.0 python=3.11.15` |\n| `CONFIG` | INFO | Startup | `_STARTUP_TS=1782950206 HOME=\u002Fhome\u002Fmoses` |\n| `HEALTH` | INFO | `\u002Fapi\u002Fv1\u002Fhealth` complete | `m total=0.3s resources=0.1s services=0.2s crons=0.0s mycortex=0.0s` |\n| `COMPACT` | INFO | `\u002Fhealth` or `\u002F` complete | `e total=20.1s resources=0.0s services=0.1s crons=0.0s mycortex=20.0s` |\n| `SLOW CHECK` | INFO | Any single check > 2s | `mycortex_sources took 4.5s` |\n| `SLOW COMPACT HEALTH` | WARN | Total > 5s | `m took 20.1s` |\n| `DEADLINE EXCEEDED` | WARN | mycortex check hit 20s cap | `mycortex_sources did not finish in 20.0s (20.0s elapsed)` |\n| `DEADLINE ERROR` | ERROR | mycortex check threw exception | `mycortex_sources failed after 3.2s: [Errno 12] Cannot allocate memory` |\n| `CHECK FAILED` | ERROR | Any check threw exception | `services crashed after 0.1s\\\\nTraceback...` |\n| `SHUTDOWN` | WARN | Process exiting (signal) | `received signal 15, exiting` |\n\n**mycortex cache TTL:** The mycortex_sources check caches its result for **900 seconds**\n(15 minutes) to avoid running the expensive `mycortex doctor --json` subprocess on\nevery request. The original 300s (5 min) TTL was bumped to reduce blocking\nfrequency. Baseline timing on a healthy system: `mycortex doctor --json` takes\n**~31 seconds** (only ~1s CPU — the rest is I\u002FO waiting on Ollama embeddings for\nsync freshness checks). The cache is invalidated after TTL expires, but the 20s\ndeadline ensures the endpoint never blocks more than 20s even when the cache is cold.\n\n**Process restart tracking:** The mycortex_sources check runs in a `ThreadPoolExecutor`\nwith a hard 20-second deadline. If exceeded, the endpoint returns a degraded response\n(`mycortex_sources_ok = -1`) instead of blocking the entire health endpoint. Check\nrestart count with:\n\n```bash\n# Total restarts since service started\nsystemctl --user show com.hermes.health-server.service -p NRestarts\n\n# Recent crashes with exit codes\njournalctl --user -u com.hermes.health-server.service --since \"1 hour ago\" --no-pager | grep -E \"STARTING|SHUTDOWN|CHECK FAILED|DEADLINE\"\n```\n\n**Key diagnostic procedure (RETIRED server, historical):** when the retired\nhealth endpoint timed out:\n\n1. Check if process is running: `systemctl --user status com.hermes.health-server.service` (historical — the CURRENT unit is `health-vector.service`)\n2. Read recent logs for DEADLINE EXCEEDED lines — they tell you which check is hanging\n3. Look for CHECK FAILED lines with tracebacks — crash evidence\n4. Check if OOM-killed: `dmesg | grep -i \"health-server\" | grep -i \"killed\"`\n5. Check if other services are destabilizing the system (see Ollama GPU crash pitfall below)\n\nSee `references\u002Fhealth-server-logging-diagnostics.md` for full details.\n\n### `health-vector.py` — Lightweight standalone probe\n\n### 2. `orch-health-report.py` — Orchestrator poller (HTTP + inbox state)\n\nRuns as a `no_agent` cron on Moses (`orch-health-report-weekday` hourly M-F 9-18,\n`orch-health-report-saturday`). Reads `agent-registry.json` to find agents and\ntheir `health_method`. (The former `orch-team-health.py` poller was **removed\nfrom the repo** in commit `69e3cf8e` — superseded by `orch-fleet-watchdog.py`\nfor state-change alerting; the hourly report is `orch-health-report.py`.)\n\n**Two fetch strategies:**\n\n| health_method | Strategy | Description |\n|---------------|----------|-------------|\n| `\"http\"` | HTTP GET | Poll `health_url` endpoint (e.g. `http:\u002F\u002Fagent:13007\u002F`) |\n| `\"inbox\"` | Bus state read | Read latest vector from `~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json` (persisted by `orch-clean-health-queue` every 10 min), fallback to a live `bus_read(\"inbox_health_check\")` |\n\n```python\ndef _fetch_http(url: str, auth: str = \"\") -> dict | None:\n    \"\"\"HTTP GET to a health-vector endpoint. Supports Basic Auth.\"\"\"\n    headers = {\"Accept\": \"application\u002Fjson\"}\n    if auth:\n        # Auth sent to inbox endpoint (not health endpoint — health has none)\n        headers[\"Authorization\"] = f\"Basic {encoded}\"\n    with urlopen(url, timeout=5, headers=headers) as resp:\n        return json.loads(resp.read().decode())\n```\n\n```python\ndef _fetch_inbox(agent_key: str) -> tuple[dict | None, str | None]:\n    \"\"\"Read the latest health ping for an inbox agent from persisted bus state.\n\n    Returns (parsed_health_data, ts_iso) or (None, None).\n    The ``orch-clean-health-queue`` cron drains ``inbox_health_check`` every\n    10 min and persists each agent's latest vector to\n    ``~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json`` — this reads that file\n    (with a live queue peek as fallback).\n    \"\"\"\n    state_file = Path.home() \u002F \".steadfaste-fleet\" \u002F \"state\" \u002F \"inbox-health-state.json\"\n    try:\n        if state_file.exists():\n            state = json.loads(state_file.read_text())\n            entry = state.get(agent_key)\n            if entry and isinstance(entry.get(\"vector\"), list):\n                return {\"v\": entry[\"vector\"]}, entry.get(\"ts\", \"\")\n    except (json.JSONDecodeError, OSError):\n        pass\n    return None, None\n```\n\n**Timeout:** 5 seconds per agent (was 3s — increased to handle transient SSL handshake jitter on external endpoints). Short enough that 5 unreachable agents don't block the poller (~25s total). Remote endpoints behind SSL\u002Fnginx can have brief DNS\u002FTCP jitter that exceeds 3s — 5s gives headroom for transient blips without hanging on real outages. If an agent doesn't respond in 5s, it's unreachable.\n\n**Inbox flow (client-only agents, current):** The retired file-inbox anchor-keep\npattern (keep oldest ping, DELETE newer ones via `api\u002Finbox`\u002F`api\u002Fdelete`) is\n**gone** — the `api\u002Finbox` endpoint no longer exists on the PGMQ bus server.\nToday:\n\n1. `health-vector-push.sh` POSTs the vector to the PGMQ queue `inbox_health_check` (`\u002Fapi\u002Fpgmq\u002Fsend`, subject `health`)\n2. `orch-clean-health-queue` (every 10 min) drains the queue, archives each ping, and persists the latest vector per agent to `~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json`\n3. `orch-health-report.py` reads that state file (fallback: live `bus_read` peek)\n\nNo accumulation: the queue is drained every 10 min and the state file holds at\nmost one entry per agent (always the latest ping).\n\n**Last-seen tracking:** The drain timestamp is recorded to\n`~\u002F.steadfaste-fleet\u002Fstate\u002Flast-seen.json` on each successful drain. This is used to\nsuppress Telegram alerts during laptop sleep — if no new pings arrive within a\nconfigurable window, the poller stays silent instead of alerting. Without this,\nevery lid-close would generate a 🔴 alert within 10 minutes.\n\n**State tracking:** Compares fingerprints between runs. Only alerts on **state transitions**:\n- Service was up (1) → now down (-1): alert with 🔴\n- Service was down (-1) → now up (1): resolution with ✅\n- Agent unreachable: alert with 🔴\n- Agent back online: resolution with ✅\n\n> **Watchdog pattern: silent = healthy.** When `orch-fleet-watchdog.py` produces empty stdout,\n> it means no state changed since last poll — everything is stable. Empty output is NOT\n> a sign of a broken cron. If you suspect the poller is broken, check\n> `~\u002F.steadfaste-fleet\u002Fstate\u002Fagent-health-data.json` for the latest snapshot.\n>\n> Similarly, if a client-only agent (Titus, `health_method: inbox`) shows as \"🔴 unreachable\"\n> in `orch-health-report.py`, check whether the agent has pushed health data recently\n> (`~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json` has an entry, and it's fresh).\n> For laptop agents, \"unreachable\" during sleep hours is **expected** — the\n> `last-seen.json` grace period suppresses alerts during sleep, but the health report will\n> still show the current state. See the \"Client-only agent unreachable (laptop sleep)\" pitfall below.\n\nThe bus connection is read from `~\u002Fsteadfaste-fleet\u002F.env`\n(`FLEET_BUS_URL` + `FLEET_BASIC_AUTH`, or Bearer `FLEET_BUS_TOKEN`). Each\nagent has their own credentials — never share the orchestrator's credentials\nwith peer agents. See `references\u002Finbox-health-format.md` for the push format,\nqueue details, and the code-duplication warning between the health scripts.\n\n**Health data** is written to `~\u002F.steadfaste-fleet\u002Fstate\u002Fagent-health-data.json`\nfor dashboard consumption.\n\n### 3. `health-vector-push.sh` — Client-only push script\n\nFor agents with no inbound access (`health_method=\"inbox\"`). Runs on a cron\u002Flaunchd schedule:\n\n```bash\n# Determines hostname, runs health-vector.py --check,\n# POSTs the JSON vector to the PGMQ bus queue inbox_health_check\n# (reads FLEET_BUS_URL + FLEET_BASIC_AUTH from ~\u002Fsteadfaste-fleet\u002F.env)\nbash ~\u002Fsteadfaste-fleet\u002Fops\u002Fscripts\u002Fhealth-vector-push.sh\n```\n\n**macOS launchd plist** at `docs\u002Ftemplates\u002Fcom.hermes.health-push.plist`:\n```xml\n\u003Cdict>\n    \u003Ckey>Label\u003C\u002Fkey>\n    \u003Cstring>com.hermes.health-push\u003C\u002Fstring>\n    \u003Ckey>ProgramArguments\u003C\u002Fkey>\n    \u003Carray>\n        \u003Cstring>\u002Fbin\u002Fbash\u003C\u002Fstring>\n        \u003Cstring>-c\u003C\u002Fstring>\n        \u003Cstring>exec \"$HOME\u002Fsteadfaste-fleet\u002Fops\u002Fscripts\u002Fhealth-vector-push.sh\"\u003C\u002Fstring>\n    \u003C\u002Farray>\n    \u003Ckey>EnvironmentVariables\u003C\u002Fkey>\n    \u003Cdict>\n        \u003Ckey>AGENT_NAME\u003C\u002Fkey>\n        \u003Cstring>titus\u003C\u002Fstring>\n        \u003Ckey>PATH\u003C\u002Fkey>\n        \u003Cstring>\u002Fopt\u002Fhomebrew\u002Fbin:\u002Fusr\u002Flocal\u002Fbin:\u002Fusr\u002Fbin:\u002Fbin\u003C\u002Fstring>\n    \u003C\u002Fdict>\n    \u003Ckey>StartInterval\u003C\u002Fkey>\n    \u003Cinteger>600\u003C\u002Finteger>  \u003C!-- 10 minutes -->\n    \u003Ckey>RunAtLoad\u003C\u002Fkey>\n    \u003Ctrue\u002F>\n    \u003Ckey>StandardOutPath\u003C\u002Fkey>\n    \u003Cstring>\u002Ftmp\u002Fcom.hermes.health-push.log\u003C\u002Fstring>\n    \u003Ckey>StandardErrorPath\u003C\u002Fkey>\n    \u003Cstring>\u002Ftmp\u002Fcom.hermes.health-push.err\u003C\u002Fstring>\n\u003C\u002Fdict>\n```\n\nRequires `FLEET_BUS_URL` + `FLEET_BASIC_AUTH` (or Bearer `FLEET_BUS_TOKEN`) in\n`~\u002Fsteadfaste-fleet\u002F.env` (the push script reads them from there).\n**Each client agent uses their OWN credentials** — never Moses' password.\n\n### 4. `agent-registry.json` — Agent configuration (public)\n\nLocated at `ops\u002Finstall\u002Fdeploy\u002Fagent-registry.template.json` (deployed to\n`~\u002F.steadfaste-fleet\u002Fstate\u002Fagent-registry.json`). The public repo version stores\nport hints in the `description` field but does NOT contain actual domain names:\n\n```json\n{\n  \"version\": 3,\n  \"agents\": {\n    \"moses\": {\n      \"name\": \"Moses\",\n      \"health_method\": \"http\",\n      \"health_url\": \"http:\u002F\u002F127.0.0.1:13007\u002Fhealth\"\n    },\n    \"gisu\": {\n      \"name\": \"Gisu\",\n      \"health_method\": \"http\",\n      \"description\": \"set health_url locally, port 13007\"\n    },\n    \"titus\": {\n      \"name\": \"Titus\",\n      \"platform\": \"macOS\",\n      \"health_method\": \"inbox\"\n    }\n  }\n}\n```\n\n### 5. `~\u002F.hermes\u002Fagent-registry.local.json` — Local override (private)\n\nActual domain URLs are configured on the orchestrator via a local override file\nin `~\u002F.hermes\u002F` (which is gitignored). The poller merges it on top of the public registry:\n\n```json\n{\n  \"version\": 3,\n  \"agents\": {\n    \"gisu\": {\n      \"health_url\": \"https:\u002F\u002F\u003Cactual-gisu-domain>:13007\u002Fhealth\",\n      \"accessible\": true\n    },\n    \"joseph\": {\n      \"health_url\": \"https:\u002F\u002F\u003Cactual-joseph-domain>:12007\u002Fhealth\",\n      \"accessible\": true\n    }\n  }\n}\n```\n\nThe override file only needs to specify the fields that differ from the public registry.\n`orch-fleet-watchdog.py` \u002F `orch-health-report.py` merge them automatically — no config change needed.\n\n### 6. `orch-health-report.py` — Health snapshot report (Telegram delivery)\n\nRuns as a `no_agent` cron producing a compact emoji-bar snapshot of every agent's\nhealth — designed for mobile Telegram display. Zero LLM tokens.\n\n**Silent-when-clean (2026-08-11, Luke directive):** the snapshot is delivered\nONLY when the fleet health signature changes — new issue, recovery, or first\nrun after deploy. Persistent identical state → empty stdout → no delivery.\nSignature is per-agent status + failing services, persisted to\n`~\u002F.steadfaste-fleet\u002Fstate\u002Fhealth-report-sig.json`. The `orch-fleet-watchdog.py`\n(5-min, transition-based) remains the primary alert channel; this hourly\nreport now mirrors it instead of pinging every hour.\n\n**Two health methods — same display code:**\n- `http` agents: `_fetch(url)` → parses `{\"v\": [...]}`\n- `inbox` agents: `_fetch_inbox_vector(agent_key)` → reads latest vector from\n  `~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json` (persisted by\n  `orch-clean-health-queue`) → parses `{\"v\": [...]}`\n\nBoth paths return the same vector format, so the emoji bar and failure listing code is shared.\n\n**Schedule:**\n| Cron | Schedule | Meaning |\n|------|----------|---------|\n| `orch-health-report-weekday` | `0 9-18 * * 1-5` | Every hour Mon-Fri 9AM–6PM KST |\n| `orch-health-report-saturday` | `0 11,17 * * 6` | Sat 11AM + 5PM KST |\n\n**Output format:**\n```\n━━━ Agent Health — Wed 10:12 UTC ━━━\n\nMoses ✅\n🟢🟢🟢🟢🟢🟢🟢🟢\n\nEsther ⚠️ 1 down\n🟢🟢🔴🟢🟢🟢🟢🟢\n  mycortex 🔴\n```\n\nThe script (`ops\u002Fscripts\u002Fagent\u002Forch-health-report.py`) reads the same agent registry\nwith local overrides as `orch-fleet-watchdog.py`, polls every agent's health\nendpoint (or reads the persisted inbox state for client-only agents), and outputs\ncompact markdown with emoji status bars.\n\n**Deployment:** Create crons with `no_agent=True` and `script=orch-health-report.py`.\nCopy the script to `~\u002F.hermes\u002Fscripts\u002F` first. See AGENTS.md for full setup.\n\n## Deployment\n\n### To install on a new server agent\n\n1. **Open the firewall port:**\n   ```bash\n   sudo ufw allow \u003CPORT>\u002Ftcp\n   ```\n   Replace `\u003CPORT>` with the agent's assigned port from the table above.\n\n2. **Install the health server as a systemd user service** (Linux) — the current\n   server is `health-vector.py`; the unit template ships in the repo:\n   ```bash\n   cp ~\u002Fsteadfaste-fleet\u002Fdocs\u002Ftemplates\u002Fhealth-vector.service ~\u002F.config\u002Fsystemd\u002Fuser\u002F\n   systemctl --user daemon-reload\n   systemctl --user enable --now health-vector.service\n   ```\n   (The retired FastAPI `health-server.py` \u002F `com.hermes.health-server.service`\n   was removed in commit `42fb8374` — do not install it.)\n\n   On macOS (launchd), run `health-vector.py --serve \u003Cport>` under a launchd\n   agent (no bundled plist; write your own with `ExecStart` pointing at\n   `~\u002Fsteadfaste-fleet\u002Fops\u002Fscripts\u002Fhealth\u002Fhealth-vector.py`).\n\n   The systemd unit uses `%h` (systemd home specifier) so it works across\n   different user accounts with zero hardcoded paths. It runs\n   `health-vector.py` with:\n   - `Restart=always`, `RestartSec=5`\n   - Logging to the systemd journal (`journalctl --user -u health-vector.service`)\n   - `Nice=10`, `IOSchedulingClass=idle` (never starves interactive work)\n\n   ⚠️ **After installing any new service, add it to `agent-service-recovery.py`'s `SERVICES` list.**\n   Otherwise a crash or SIGTERM leaves it dead until a human notices — the auto-recovery\n   script only restarts services in its watchlist.\n   See `references\u002Fservice-recovery-blind-spot.md` for the checklist and example.\n\n3. **Verify locally:**\n   ```bash\n   curl -s http:\u002F\u002F127.0.0.1:8905\u002Fhealth\n   # → {\"v\":[...], \"h\":\"moses\", \"t\":...}\n   ```\n\n4. **Set up nginx proxy** to terminate TLS and proxy `\u002Fhealth` to the internal health server:\n   ```nginx\n   server {\n       listen \u003CPORT> ssl;\n       location \u002Fhealth {\n           proxy_pass http:\u002F\u002F127.0.0.1:8905;\n       }\n   }\n   ```\n   Then verify externally with TLS:\n   ```bash\n   curl -sfk https:\u002F\u002F\u003Cagent-domain>:\u003CPORT>\u002Fhealth\n   ```\n\n5. **Set up bus config** for agent-to-agent messaging:\n   ```bash\n   # ~\u002Fsteadfaste-fleet\u002F.env\n   # Each agent uses their OWN credentials — ask Moses to create a htpasswd entry\n   FLEET_BUS_URL=\"https:\u002F\u002F\u003Cmoses-domain>:13004\"\n   FLEET_BASIC_AUTH=\"your-agent-name:\u003Cyour-password>\"\n   AGENT_NAME=\"your-agent-name\"\n   ```\n\n### To install on a client-only agent (macOS)\n\n1. **Set up bus config:**\n   ```ini\n   # ~\u002Fsteadfaste-fleet\u002F.env\n   FLEET_BUS_URL=\"https:\u002F\u002F\u003Cmoses-domain>:13004\"\n   FLEET_BASIC_AUTH=\"\u003Cyour-agent-name>:\u003Cyour-password>\"\n   AGENT_NAME=\"\u003Cyour-agent-name>\"\n   ```\n   `chmod 600 ~\u002Fsteadfaste-fleet\u002F.env`\n\n2. **Install the launchd push agent:**\n   ```bash\n   cp ~\u002Fsteadfaste-fleet\u002Fdocs\u002Ftemplates\u002Fcom.hermes.health-push.plist ~\u002FLibrary\u002FLaunchAgents\u002F\n   launchctl load ~\u002FLibrary\u002FLaunchAgents\u002Fcom.hermes.health-push.plist\n   ```\n\n3. **Test:**\n   ```bash\n   AGENT_NAME=titus bash ~\u002Fsteadfaste-fleet\u002Fops\u002Fscripts\u002Fhealth-vector-push.sh\n   ```\n   Silent = success. Errors go to `\u002Ftmp\u002Fcom.hermes.health-push.err`.\n\n## Diagnostic Procedure: \"Hourly report says 🔴 unreachable, manual run is green\"\n\n**Trigger:** The hourly `orch-health-report` (what lands in Telegram) marks an agent\n— usually Moses itself — 🔴 unreachable, but a manual `python3\n~\u002F.hermes\u002Fscripts\u002Forch-health-report.py` minutes later is green. Real outage vs\nmonitoring artifact? Run this sequence in order. (Discovered 2026-08-04: Moses\nred at 13:00\u002F14:00\u002F15:00, green at 15:03.)\n\n1. **Read the actual cron output** (not the chat paste):\n   `~\u002F.hermes\u002Fcron\u002Foutput\u002F\u003Cjob_id>\u002Flatest.md` — keyed by job ID, never name\n   (`cronjob action='list'` → `orch-health-report-weekday`). Check whether it\n   fails every run or just some (sporadic = timing; constant = config\u002Foutage).\n2. **Probe the external URL** — the ONLY health truth (localhost curls are not\n   evidence):\n   ```bash\n   curl -skS -w \"\\nHTTP=%{http_code} %{time_total}s\\n\" --max-time 15 https:\u002F\u002F\u003Cdomain>:\u003Cport>\u002Fhealth\n   ```\n3. **Measure latency repeatedly** — run 5+ probes. If responses are 2-10s, the\n   endpoint itself is slow → find the slow check:\n   ```bash\n   cd ~\u002Fsteadfaste-fleet\u002Fops\u002Fscripts\u002Fhealth && python3 - \u003C\u003C'EOF'\n   import time, importlib.util\n   spec = importlib.util.spec_from_file_location(\"hv\", \"health-vector.py\")\n   hv = importlib.util.module_from_spec(spec); spec.loader.exec_module(hv)\n   for fn in hv.CHECK_FUNCTIONS:\n       t0=time.time(); r=fn(); print(f\"{fn.__name__:\u003C28}{time.time()-t0:>7.3f}s -> {r}\")\n   EOF\n   ```\n   Any check > 1s is the culprit. As of 2026-08-04: `check_mycortex` shelled out\n   to `mycortex doctor --json` (~1.7s+) on EVERY request with no cache.\n4. **Check the health server journal for BrokenPipeError** — clients timing out\n   mid-write:\n   `journalctl --user -u health-vector.service --since \"1 hour ago\" --no-pager | grep -A6 \"line 448\"`\n   A traceback at `self.wfile.write(...)` = the poller gave up while the server\n   was still computing. Not a server crash — a symptom.\n5. **Check server concurrency**: `health-vector.py` uses `HTTPServer`\n   (single-threaded) — pollers (hourly report, fleet watchdogs, dashboard)\n   arriving within seconds at :00 serialize behind a slow request and queue\n   past their client timeouts. Fix: `ThreadingHTTPServer`.\n6. **Compare poller timeouts**: `grep -n TIMEOUT ops\u002Fscripts\u002Fagent\u002Forch-health-report.py`\n   vs `ops\u002Fscripts\u002Fagent\u002Forch-team-health.py`. (The former\n   `agent-health-monitor.py` was removed 2026-08-04 — deprecated,\n   superseded by `orch-fleet-watchdog.py`.) A 3s timeout against a\n   server that takes 2-9s under burst = guaranteed false red. Fleet guidance:\n   5s minimum for external SSL-terminated endpoints.\n7. **Fix pattern (all three layers, 2026-08-04 commit 03d95312):**\n   - slow check → short-TTL cache (60s; same pattern as the retired\n     health-server.py mycortex cache)\n   - single-threaded server → `ThreadingHTTPServer`\n   - short poller timeout → 3s → 5s\n8. **Verify through the scheduler, not manually**: `bash fleet-update.sh`\n   (deploy; purges gov locks — re-acquire), `systemctl --user restart\n   health-vector.service` (unit runs the repo file; running process needs a\n   restart to load new code), `cronjob action='run' job_id=\u003Cid>`, then confirm\n   the cron output shows ✅. Manual `python3` runs do NOT update the scheduler's\n   `last_status` or the doctor's run-evidence.\n\n**Rule of thumb:** sporadic \"unreachable\" for the self-poll only (other agents\ngreen) = timing\u002Fconcurrency on the local health server, not an outage. Check\nlatency distribution and server threading BEFORE touching the registry, nginx,\nor firewalls.\n\n## Health-Report Pitfall: Stale SERVICE_MAP\n\nThe orchestrator poller (`orch-health-report.py`) has a hardcoded `SERVICE_MAP` that maps vector indices to service names. Over time, if the agent-side health endpoint changes format (e.g. from 8-element `health-vector.py` to 9-element `health-server.py`), the poller's map becomes stale and misreports every vector.\n\n**Verification procedure when adding a new agent or after a health-endpoint update:**\n\n1. Poll the new\u002Fupdated endpoint directly: `curl -sS --max-time 5 https:\u002F\u002F\u003Cagent-url>\u002Fhealth`\n2. Count the vector elements — is it 8 or 9?\n3. Read the agent's `health-server.py`\u002F`health-vector.py` `_build_compact_health()` function to confirm the exact index-to-service mapping\n4. Update `SERVICE_MAP` in `orch-health-report.py` to match\n5. **Also update** `health_vector_map` in `agent-registry.json` — it must match the same order\n6. Run the poller once manually (`python3 ops\u002Fscripts\u002Fagent\u002Forch-health-report.py`) and verify the output shows the correct service names\n\n**Real example:** Remote agents run `health-server.py` which produces a 9-element vector `[resources, services, no_errored_crons, no_stale_crons, nginx, ollama, mycortex, disk_ok, mycortex_sources_ok]`. The poller had an 8-element map from the old `health-vector.py` template `[nginx, ollama, mycortex, cortex-dashboard, langfuse-web, langfuse-worker, docker, hermes-gateway]`, causing index 3 = -1 to report as \"cortex-dashboard down\" when it actually meant \"stale cron jobs\".\n\n---\n\n| Pitfall | Symptom | Fix |\n|---------|---------|------|\n| **Public repo PII** | Actual domain names committed to the public steadfaste-fleet repo | Use `~\u002F.hermes\u002Fagent-registry.local.json` for real URLs. The public repo stores port hints only. |\n| **Health URL uses internal address** | Poll passes locally but fails from orchestrator because the path bypasses nginx\u002FTLS. See `references\u002Fagent-registry-structure.md` for rules on external vs internal URLs, hostname vs host conventions, and example-file sync. | Always use the externally-reachable nginx SSL URL as `health_url`. Poll `https:\u002F\u002Fdomain:PORT\u002Fhealth` not `http:\u002F\u002F127.0.0.1:8905\u002Fhealth`. |\n| **Sharing orchestrator credentials** | Peer agents get Moses' htpasswd password. If one is compromised, all are. | Each agent gets their own htpasswd entry. `sudo htpasswd \u002Fetc\u002Fnginx\u002F.hermes-htpasswd \u003Cagent-name>` on Moses' server. |\n| **pgrep -x -f combined** | `_pgrep(\"gateway run\", full=True)` with `exact=True` default produces `pgrep -x -f \"gateway run\"` which requires exact command-line match (full string), not substring | Use `_pgrep(\"gateway run\", exact=False, full=True)` to produce `pgrep -f \"gateway run\"` for substring match |\n| **Agent registry uses dict key, not name** | Duplicate agent entries in health data — one with key from registry, another from fallback | Registry entries use the dict key (e.g. \"moses\") as the agent key, not the `name` field (e.g. \"Moses\"). The fallback check must compare against the same namespace. |\n| **Fleet Dashboard uses \"overall\" not \"healthy\"** | Legacy format handler reports healthy=False when services are actually up | Dashboard returns `{\"overall\": \"healthy\"}`, not `{\"healthy\": true}`. Check `data.get(\"overall\") == \"healthy\"`. |\n| **Compact format has different indices from legacy** | You see vector[3] = -1 and assume \"Fleet Dashboard\" is down. Actually it means \"stale cron jobs\" in the deployed compact format. | Always check the backend script serving the endpoint. `health-server.py` → compact 9-element format. `health-vector.py` → can serve either format; check CHECK_FUNCTIONS length. |\n| **`-1` means \"unhealthy\u002Fwarning\", not \"down\"** | The compact format has no `0` (n\u002Fa) — every index is always `1` or `-1`. A stale cron job (index 3) returns `-1` but the service is not \"down\" — it just hasn't run recently. See `references\u002Fschedule-aware-stale-detection.md` for how the stale threshold is computed from cron expressions (replaces hardcoded 24h). | Understand the semantics: `-1` may indicate a warning condition, not necessarily a service outage. |\n| **`-1` for uninstalled services** | Agents without a given binary (e.g. nginx on a macOS dev box) report `-1` because the check function only looks for the running process. Titus' nginx = -1 is misleading — it's not \"nginx is down\", it's \"nginx doesn't exist on this machine\" | Per-service checks (`check_nginx()`, `check_ollama()`, `check_mycortex()`) now use `shutil.which()` to detect if the binary exists. Returns `0` (not applicable) if not found. `check_services()` also returns `0` if no services are installed on the system (macOS fallback). See `references\u002Funinstalled-service-detection.md`. |\n| **External endpoint timeout sensitivity** | Agents behind nginx SSL (Moses 13007, Joseph 12007, Esther 14007) occasionally get marked \"unreachable\" even though they respond in ~0.1s — DNS\u002FTCP jitter on the HTTPS handshake spikes past the 3s timeout | Use 5s timeout for the orchestrator poller. 3s is fine for localhost (127.0.0.1) but external SSL-terminated endpoints need headroom. Polls every 10m — 5s per agent doesn't block the cycle. |\n| **Orchestrator self-poll must use external HTTPS URL** | When the orchestrator polls itself (Moses polls Moses), the code fallback defaults to `http:\u002F\u002F127.0.0.1:13007\u002F` — plain HTTP to a port nginx serves with `ssl` only. Nginx returns 400 \"plain HTTP sent to HTTPS\" → poll fails. | The self-poll URL MUST use the external HTTPS domain through nginx (e.g. `https:\u002F\u002Fdomain:13007\u002Fhealth`). Configure this via `agent-registry.local.json` — set Moses' `health_url` to the same external URL other agents use to reach Moses. The code fallback is a dev-only safety net that doesn't work when the nginx health block is SSL-only. Verify: `curl -sk https:\u002F\u002F$(hostname -f):13007\u002Fhealth` should succeed. If it doesn't, the registry URL is wrong or the nginx health block is misconfigured. |\n| **Long timeout on unreachable agents** | Poller takes 60+ seconds when 4+ agents are down | Short timeout (5s). The poller runs every 10 minutes. If an agent doesn't respond in 5s, it's unreachable. |\n| **Client-only agent unreachable (laptop sleep)** | Without the last-seen grace tracking, Moses alerts every 10 min when a laptop closes its lid. The `last-seen.json` grace period handles this naturally — pings stop during sleep, but alerts are suppressed within the window. See `docs\u002Fagent-onboarding.md` for the agent-side setup. |\n| **Agent has nginx running but is NOT a server** | If a client-only agent (Titus) has nginx installed for local dev, you might assume it's now reachable as a server | nginx on a dev machine does NOT make it a server. Client agents ALWAYS use `health_method: inbox` — never add a `health_url` for them, even if nginx is running. The presence of a web server does not imply reachability. Check `is_server` in the agent registry before setting up polling. |\n| **Agent has inbox on the same port as health** | Gisu had inbox on 13004, can't put health on the same port | Use a different port scheme. Moses\u002Finfra agents: 13007. Joseph: 12007. Esther: 14007. Avoid conflicts with existing inbox\u002Fdashboard ports. |\n| **Triple-sync requirement: SERVICE_MAP, CHECK_FUNCTIONS, --check labels** | You update the SERVICE_MAP docstring to 9 elements but the actual CHECK_FUNCTIONS list still returns 8 → the endpoint returns wrong vector length and downstream pollers misdiagnose every index | Always update all three: (1) SERVICE_MAP doc comment, (2) CHECK_FUNCTIONS list, (3) --check labels. Verify with `curl -s http:\u002F\u002F127.0.0.1:\u003CPORT>\u002F` and count elements. Run `python3 health-vector.py --check` to validate labels match. Commit to repo after testing. |\n| **Health queue backlog (drain stopped)** | Health pings accumulate in `inbox_health_check` (queue depth grows, `inbox_watch` returns MB-sized results). Means the `orch-clean-health-queue` cron stopped, or the push script targets the wrong queue. Check queue depth: `docker exec mycortex-postgres psql -U mycortex -d mycortex -t -c \"SELECT state, COUNT(*) FROM bus.messages WHERE queue_name='inbox_health_check' GROUP BY state;\"` and the cron's last run. |\n| **Consumer-producer sync: update consumer after verifying producer format, not before** | | You update the orchestrator health report script (consumer) to handle a format you assume Titus sends, without first verifying what he actually pushes | Pull the latest data from the producer first — read their actual format, test the endpoint, THEN update the consumer. Never update a consumer based on assumptions about the producer's format. The workflow is: (1) check what the producer sends, (2) write consumer to match, (3) verify both directions. |\n| **Dashboard `_find_pid()` does literal substring, not regex** | Service patterns like `legacy.*autopilot`, `[o]llama serve` use `.*` regex syntax, but `_find_pid()` does `if pattern_lower in line.lower()` — a literal substring check. The dot-star is never matched as a wildcard. | Use actual substrings that appear in `ps aux` output: `\"legacy autopilot\"` not `\"legacy.*autopilot\"`, `\"ollama\"` not `\"[o]llama serve\"`. The patterns in `server.py`'s `_health()` dict must match the literal process command line. Verify by grepping `ps aux` for the exact substring before adding. |\n| **Rich health-report format from inbox agents** | Titus pushes a JSON health report with services, issues, resources, uptime fields — not a compact `{\"v\": [...]}` vector. The `_parse_vector_body()` function in `orch-health-report.py` doesn't handle this format and returns `None`, marking the agent as unreachable. | `_parse_vector_body()` must detect `\"type\": \"health-report\"` in the JSON body and route to a rich-report parser (`_parse_rich_report()`) that converts the rich data to a vector while preserving metadata under a `_rich` key for `_build_structured_data()` to use. See `references\u002Frich-health-report-format.md`. |\n| **Health queue pings dropped before report reads them** | The hourly report finds no vector for an inbox agent because `orch-clean-health-queue` already drained and archived the pings (queue is transient). | The drain cron persists each agent's latest vector to `~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json`; the report reads that file (live queue peek is only a fallback). If Titus shows 🔴, check that file exists and is fresh — if missing, the drain cron is not running. |\n| **Inbox agents show 🔴 because report still calls retired `api\u002Finbox`** | Report queries `GET \u002Fapi\u002Finbox?...` which returns 404 on the PGMQ bus (endpoint removed in the inbox→PGMQ migration, commit `0f01556d`). Every inbox agent shows 🔴 unreachable despite healthy pushes; last-seen stays stale. | `_fetch_inbox_vector()` must read `inbox-health-state.json` (or `bus_read(\"inbox_health_check\")`), NOT `api\u002Finbox`. Fixed 2026-08-04 — see the implementation in `orch-health-report.py` and `orch-clean-health-queue.py`. |\n| **Endpoint path is `\u002Fhealth`, not bare `\u002F`** | Poller gets 404 on the root endpoint | The health-vector server serves at `GET \u002Fhealth`, not `GET \u002F`. `curl -s http:\u002F\u002F127.0.0.1:8905\u002Fhealth`, not `http:\u002F\u002F...:8905\u002F`. |\n| **Sharing untested URLs** | User calls you out for sending configs without verification | Test EVERY endpoint with `curl --max-time 5` from the external perspective before sharing with the user or peer agents. Do NOT only test from localhost — that only proves nginx is up locally. Check from the agent's perspective by reading the nginx access log for their IP or by using an external port checker. When an agent reports a connectivity issue, test ALL external endpoints (dashboard, langfuse, inbox, health) before diagnosing — a single endpoint being down vs all being down tells you whether it's a per-service or per-server\u002Fnetwork problem. |\n| **Old `com.hermes.health-server.service` vs current `health-vector.service`** | Docs mention a FastAPI `health-server.py` service on port 8905 — it was **removed from the repo** (July 2026). If `com.hermes.health-server.service` still exists on a machine it's an orphan from a pre-removal deploy. | The **current** canonical server is `health-vector.service` running `health-vector.py --serve 8905` (9-element compact vector, schedule-aware stale detection). If both units exist, disable the orphan: `systemctl --user disable --now com.hermes.health-server.service && systemctl --user enable --now health-vector.service`. Verify with `systemctl --user list-units | grep health`. |\n| **`check_services()` returns -1 when none are installed** | On macOS or agents without nginx\u002Follama\u002Fmycortex, `check_services()` iterates all key services and returns -1 if any is missing — even if the service isn't supposed to be there. | Fix: detect whether any key service is **installed** before checking. On Linux, check systemd unit existence. If none are present, return `0` (not applicable). On macOS, if no relevant processes are found via pgrep, return `0` instead of `-1`. |\n| **Ollama GPU crash cascade** | Health endpoint times out because Ollama crashes the GPU driver (Vulkan on old Intel HD 4000 iGPU, Ivy Bridge 2012). Ollama's vk::DeviceLostError destabilizes system resources, causing the health server to OOM-restart repeatedly (23+ restarts observed). The health vector looks broken but it's actually a cascading failure from Ollama. | Force Ollama to CPU-only on machines with old\u002Fincompatible GPUs: set OLLAMA_GPU_LAYER=false (or --cpu flag). On Ivy Bridge \u002F HD 4000 era hardware, the iGPU does not support Vulkan fully. Check restart count: systemctl --user show com.hermes.health-server.service -p NRestarts. Check ollama journal: journalctl --user -u ollama.service --since 1 hour ago --no-pager. If you see vk::DeviceLostError in ollama logs, the GPU is the root cause. |\n| **Orphan service: `Loaded: not-found` + `Active: active (running)`** | `systemctl --user status \u003Cservice>` shows `Loaded: not-found` but the service is still running. The unit file was deleted\u002Fremoved but the process from a previous load is alive. It will NOT auto-start on reboot. | Don't restart blindly — that fails because the unit file is missing. Find the source unit (check repo `ops\u002Finstall\u002F` or private repo) and re-install: `cp \u003Csource> ~\u002F.config\u002Fsystemd\u002Fuser\u002F && systemctl --user daemon-reload && systemctl --user restart \u003Cservice>`. If no source unit exists, the service was intentionally removed — stop the orphan cleanly. Cross-reference with `ss -tlnp | grep python3` to match ports to PIDs. |\n| **Bus liveness vs health vector disagreement** | Agent shows offline (bus audit log) but green (HTTP health vector). You investigate a non-issue. | Check both signals before deciding. Bus-offline + health-green = alive but idle. Bus-offline + health-down = real problem. See the Two Orthogonal Monitoring Systems section above. |\n| **Paused cron trips stale\u002Ferrored checks (FIXED 2026-07-31)** | A paused job (`enabled: false`, e.g. `orch-bus-forwarder-sync` paused for maintenance) keeps its old `last_run_at`. The stale check computes elapsed vs its schedule (e.g. `*\u002F2 * * * *`) and flags it permanently stale — health index 3 red forever. Same for a paused job with a frozen `last_status: error`. | `check_no_stale_crons()` and `check_no_errored_crons()` skip jobs with `enabled != true`. Paused jobs are intentionally not running — their frozen timestamps\u002Fstatuses must not drive the health vector. If health index 2 or 3 is red, first check whether the offender is paused before blaming the cron. |\n| **Bounded hour-range schedules flagged stale overnight (FIXED 2026-08-19, commit 90573ba9)** | Both orchestrators show index 3 = -1 (`no_stale_crons`) every night while a fresh local `python3 health-vector.py` run is all-green. Root cause: a cron with a bounded hour range (e.g. `0 8-22 * * *`, `orch-backlog-driver`) had its max legit silence computed as 1h (the `-` branch returned 3600), so after 2h of overnight silence it was flagged stale. The fix returns the overnight wrap gap `(24 - b + a) * 3600`. **Deploy lag:** the repo\u002Fdeployed script were already fixed but the long-lived `health-vector.service` process (running since Aug 13) held the old code in memory — a process restart is required after ANY health-vector.py change (`systemctl --user restart health-vector.service`); the file copy alone never reloads it. Verify via the EXTERNAL URL, not localhost. | After any `health-vector.py` edit: restart `health-vector.service` on the host AND its peer orchestrator (moses↔esther both run it). Diagnosis signature: external endpoint `-1` at index 3 while a fresh local script run returns `1` = stale in-memory code, not a real stale cron. Check `systemctl --user status health-vector.service` uptime vs the repo commit date. |\n| **Gateway restart interrupts in-flight LLM crons** | A gateway restart (\"Stopping gateway for restart...\", drain timeout at 180s) kills in-flight cron sessions. They are marked `interrupted` → `last_status: error` with NO output file written. Health index 2 goes red until each cron completes a new run. All affected crons share the exact same `last_run_at` timestamp (the interruption moment). | Not a cron bug — recovery is automatic on the next scheduled run. Verify: same-timestamp errors across several crons + gateway shutdown log lines at that moment. To confirm the crons re-ran, check `~\u002F.hermes\u002Flogs\u002Fagent.log` for new `cron_\u003Cjobid>_\u003Cnewer-timestamp>` sessions. If the red persists past the next run, then investigate the cron itself. |\n| **Errored cron feeds health vector index 2** | Health shows -1 at index 2 (no_errored_crons). A watchdog exited non-zero legitimately detecting a real problem (e.g. ClickHouse merge failures from langfuse-health-watchdog). | Read the failing cron output from cron output dir. Fix the underlying problem, not the health check. The watchdog and health vector are working correctly. |\n| **Persistent index-2 red on a REMOTE agent (2026-08-11)** | A remote agent's vector shows `no_errored_crons` red for hours with no transition — the fleet watchdog stays silent (transition-based) and, since 2026-08-11, the hourly report also stays silent on unchanged state. The red is invisible until it flips. | Diagnose proactively via fleet EXEC: `fleet send \u003Cagent> EXEC '{\"command\":\"fleet-doctor.py\",\"params\":[\"--quiet\"],\"timeout\":240,\"output_schema\":\"RAW\"}' --self-tested`, then poll `bus.archives` for `EXEC_RESULT` (~5.5 min). The doctor output names the errored cron (`⚠️ Cron status (\u003Cname>) — last run: error`). Fix in the repo, then `UPDATE_REQUEST` the agent. Note: a remote agent N commits behind also fails updates until it pulls — check `git_sha_after` in the UPDATE_RESULT, not just `success` (see fleet-commands skill). |\n| **Sporadic self-poll \"unreachable\" while manual run is green (FIXED 2026-08-04)** | Hourly report marks Moses 🔴 unreachable at :00 while a manual run minutes later is green. Root cause chain: `check_mycortex` runs `mycortex doctor --json` (~1.7s+) on every request with no cache → single-threaded `HTTPServer` serializes the :00 poller burst → 2-9.6s wall times → report's 3s timeout fires → BrokenPipeError in the server journal. Other agents stay green because their endpoints are on other hosts. | Three-layer fix (commit 03d95312): cache the slow check (60s TTL), `ThreadingHTTPServer`, poller `TIMEOUT` 3→5. Diagnostic steps in the \"Diagnostic Procedure\" section above. |\n| **Laptop agent shows green forever after it stops pushing (FIXED 2026-08-04)** | Inbox-method agent (Titus) stops pushing health pings, but the hourly report keeps showing ✅ green indefinitely. `_fetch_inbox_vector` read the persisted vector from `inbox-health-state.json` unconditionally — no staleness check — so the 30-min grace \u002F 🔴 unreachable logic never engaged. (Found 2026-08-04: Titus pushed until 18:48 KST then stopped; report still showed 9 greens at 19:20.) | Freshness gate in the state-file read (commit 16400583): if the persisted vector's `ts` is older than `LAPTOP_GRACE_MINUTES`, return None so the caller applies the offline\u002Funreachable path. A laptop agent that is not pushing must show unavailable — never stale green. |","# Agent Health Monitoring\n\n## ⚠️ Mandatory Health Verification Protocol — FOLLOW EVERY TIME\n\nBefore claiming any agent is healthy or reporting health status, execute these steps **in order**. Localhost checks are NOT sufficient — external reachability is the only valid measure.\n\n### Step 1: Identify the external health URL\n\nFor the current agent (Moses), read `FLEET_HEALTH_URL` from `.env`:\n```bash\ngrep FLEET_HEALTH_URL ~\u002Fsteadfaste-fleet\u002F.env\n# → https:\u002F\u002Fexample.com:13007\u002Fhealth\n```\n\nFor remote agents in the registry, read `health_url` from `agent-registry.json` (merged with local overrides from `~\u002F.hermes\u002Fagent-registry.local.json`). The public registry's `http:\u002F\u002F127.0.0.1:PORT\u002Fhealth` defaults are LOCALHOST PLACEHOLDERS — never trust them as the external truth.\n\n### Step 2: Probe the external URL\n\n```bash\ncurl -sS --max-time 10 \u003CEXTERNAL_HEALTH_URL>\n```\n\nThis returns the full vector (e.g. `{\"v\":[1,1,-1,1,1,1,1,1,1],\"h\":\"m\",\"t\":...}`). Use the external response. Discard any localhost-only curl you ran earlier — it does not count.\n\n### Step 3: Decode every non-1 element\n\nFor each `-1` in the vector:\n- **Index 0** → resources (CPU\u002Fmemory\u002Fdisk)\n- **Index 1** → services (nginx, ollama, mycortex, etc.)\n- **Index 2** → no_errored_crons — check `cronjob action='list'` for `last_status != \"ok\"`\n- **Index 3** → no_stale_crons\n- **Index 4** → nginx\n- **Index 5** → ollama\n- **Index 6** → mycortex\n- **Index 7** → disk\n- **Index 8** → mycortex_sources\n\n### Step 4: Diagnose each issue\n\nFor errored crons (index 2 = -1): find the failing cron by checking the cron list for errors, then read that cron's output from `~\u002F.hermes\u002Fcron\u002Foutput\u002F\u003Cjob_id>\u002Flatest.md`.\n\n### Step 5: Report honestly\n\nState: \"External URL: \u003Curl> → vector, [x] of [9] green, [n] issues: \u003Clist>\". Never claim \"healthy\" or \"green\" unless the external URL returned all 1s.\n\n> **Common failure:** You curl localhost (127.0.0.1:8905 or 127.0.0.1:13007), it returns all-1s, and you claim healthy. Meanwhile the external URL returns -1 at index 2 because a cron errored. Localhost bypasses nginx TLS and may serve cached\u002Fstale data. The external URL is the source of truth.\n\n---\n\n> **Principle: Verify before building.** When diagnosing fleet health issues, first verify the existing registry covers all known agents. The `agent-registry.json` + `agent-registry.local.json` should list every agent. Do not build speculative registration or discovery infrastructure when the registry is already populated. If an agent is unreachable, check whether it's a server (HTTP-polled) or client-only (inbox-pushed) agent before building new communication channels.\n\nMonitor agent servers via a **binary status vector** — a compact JSON payload\nwith deliberately **no authentication** because the data is minimal\n(just `1`=up, `-1`=down, `0`=n\u002Fa per service). The vector contains no secrets,\nno PII, no version info — just eight bytes of binary flags.\n\n> **Key design decision:** Health endpoints run on plain HTTP with no auth.\n> Putting a binary status vector behind Basic Auth adds latency and token overhead\n> for zero security value. The agent inbox (which carries actual messages) still\n> uses per-agent credentials. See PITFALLS below.\n\n## ⚠️ Two Vector Formats in Play\n\nThere is **one** deployed health vector format in the ecosystem. Earlier\ndocumentation described a FastAPI `health-server.py` variant — that file was\n**removed from the repo** (July 2026, commit `42fb8374`, \"remove redundant\nFastAPI health-server\") and `health-vector.py` running via `health-vector.service`\nis the **only** deployed server. Do not look for `health-server.py` — it does\nnot exist in the repo and is not deployed anywhere in the fleet.\n\n| Format | Source | Vector length | Indices mean | Used by |\n|--------|--------|---------------|--------------|---------|\n| **Compact health** | `health-vector.py` → `CHECK_FUNCTIONS` \u002F `get_vector()` | **9 elements** | Aggregated check results (see below) | Every deployed health endpoint (`:13007\u002Fhealth`, `:12007\u002Fhealth`, `:14007\u002Fhealth` — nginx proxy to `:8905`) |\n\n### Compact Health Format (DEPLOYED) — 9-element `v` array\n\nThis is the format returned by every deployed health endpoint\n(`health-vector.py` via `health-vector.service` — see\n`references\u002Fhealth-vector-schema-migration.md` for the 8→9 element migration).\n\n```python\nv = [\n    1 if resources_ok else -1,         # [0] resources — CPU\u002Fmemory\u002Fdisk within limits\n    1 if services_ok else -1,          # [1] services — all critical services are running\n    1 if no_errored else -1,           # [2] no errored crons — all cron jobs ran without error\n                                       #     ⚠️ See references\u002Fwatchdog-vs-crash-semantics.md\n                                       #     \"errored\" includes watchdog scripts that correctly\n                                       #     exited non-zero on detection — not just crashes\n    1 if no_stale else -1,             # [3] no stale crons — schedule-aware (2x expected interval, not hardcoded 24h)\n    1 if nginx_ok else -1,             # [4] nginx — pgrep nginx\n    1 if ollama_ok else -1,            # [5] ollama — pgrep ollama\n    1 if mycortex_ok else -1,            # [6] mycortex — pgrep mycortex\n    1 if disk_ok else -1,              # [7] disk — disk usage \u003C 80%\n    1 if mycortex_sources_ok else -1,    # [8] mycortex sources — all mycortex sources healthy\n]\n```\n\n**Semantics:** `1` = healthy, `-1` = unhealthy\u002Fwarning, `0` = not applicable \u002F not installed on this system.\n\n| Value | Meaning |\n|-------|---------|\n| `1` | Service is running or condition is satisfied |\n| `0` | Service is **not installed** on this agent (nginx on a macOS dev box, mycortex on a minion, etc.) |\n| `-1` | Service IS installed but **not running**, or condition is violated |\n\nThe `0` value is supported by `health-vector.py`'s check functions. Each\nper-service check now uses `shutil.which()` to detect if the binary exists\nbefore probing for the running process — returns `0` if not found.\n\n`health-server.py` (FastAPI variant, **removed in commit `42fb8374`**) still only\nreturned `1` or `-1` since it aggregated checks per-machine where all services\nshould be present. Only `health-vector.py` is deployed — see the retired-server\nnote in the diagnostics section below.\n\n### A capability check reports on the capability's OWN tool — never on a copy of its knowledge\n\nWhen adding a check for something the fleet ships per-object — harnesses, skills, provider\nintegrations, MCP servers — hold the check to the same split the `0` semantics above already\nencode:\n\n- **Knowledge of what each object needs lives in that tool's own registry, not in the check.**\n  A second copy inside the check goes stale the moment an object is added, and the check then\n  reports on an old world. Iterate the registry and report ONE line per declared object.\n- **Drive the tool's own CLI to decide the verdict**, rather than re-implementing the decision\n  in the check. One implementation of \"is this capability wired correctly\" is the only way the\n  check and the CLI cannot disagree.\n- **Read the registry THROUGH that CLI, not by importing a parser.** The check may run under a\n  bare `python3` (a deploy path often does), and an `import yaml`-shaped read then downgrades\n  every object to could-not-verify on a healthy host. Two extra rules: a registry the CLI cannot\n  read is reported as could-not-verify with the CLI's own rc, and a missing interpreter is exit\n  `3` — never `1`, which reads as \"the capability is broken\". Resolver recipe: `shell-scripting`\n  → \"Resolving an Interpreter by CAPABILITY\".\n- **Keep the four outcomes distinct: PASS \u002F WARN \u002F SKIP \u002F could-not-verify.** Not-installed is a\n  SKIP (the `0` rule above) and must not be counted as a fault; \"declared unsupported\" is a SKIP\n  carrying the registry's OWN reason, not the generic not-installed wording — the two read\n  differently to whoever has to act on them.\n\n### Legacy Health Vector Format (NOT DEPLOYED) — 8-element `v` array\n\nFrom the old `health-vector.py` template. Not actively deployed but may be\nreferenced in older documentation or templates.\n\n| Index | Service | Code |\n|-------|---------|------|\n| 0 | nginx | 1=up, -1=down, 0=n\u002Fa |\n| 1 | Ollama | same |\n| 2 | mycortex | same |\n| 3 | Fleet Dashboard | same |\n| 4 | Langfuse web | same |\n| 5 | Langfuse worker | same |\n| 6 | Docker | same |\n| 7 | Hermes Gateway | same |\n\n### Critical: Never assume index meaning across formats\n\nIf you see vector index 3 = -1, it means:\n- **In compact format (DEPLOYED):** Stale cron jobs (no_stale = False)\n- **In legacy format:** Fleet Dashboard is down\n\n**Always check which format the endpoint serves** before diagnosing.\nSee `references\u002Fcompact-health-vector-format.md` for detailed source\ncode reference.\n\n## Architecture\n\n```\n                        ┌──────────────────────┐\n                        │  Agent Registry v3+   │\n                        │  health_method per     │\n                        │  agent in JSON         │\n                        └───────┬──────────────┘\n                                │\n                                ▼\n┌──────────────────────────────────────────────────────┐\n│  Moses (orchestrator)                                 │\n│  orch-health-report.py (hourly) \u002F                     │\n│  orch-fleet-watchdog.py (5 min)                       │\n│                                                       │\n│  for each agent:                                      │\n│    if health_method == \"http\":  ──→ HTTP GET :PORT    │\n│    if health_method == \"inbox\": ──→ read inbox_       │\n│                                     health-check      │\n│                                     state file        │\n│                                                       │\n│  State tracked by fingerprint vector                  │\n│  Alerts only on state transitions                     │\n└─────────────────────────┬────────────────────────────┘\n                          │\n            ┌─────────────┼─────────────────┐\n            ▼             ▼                   ▼\n┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐\n│  Gisu (server)   │ │  Joseph (server) │ │  Titus (macOS)   │\n│  health-vector.py│ │  health-vector.py│ │  NO inbound      │\n│  --serve :13007  │ │  --serve :12007  │ │                  │\n│  HTTP-polled     │ │  HTTP-polled     │ │  health-vec-push │\n│                  │ │                  │ │  → PGMQ bus      │\n└──────────────────┘ └──────────────────┘ │  inbox_health_   │\n                                          │  check queue     │\n                                          │  every 10 min    │\n                                          │  (launchd plist) │\n                                          └──────────────────┘\n```\n\n- **Server agents** (health_method=\"http\"): Moses polls their health vector server directly on the agent's assigned port. Each agent has its own port (see table below).\n- **Client-only agents** (health_method=\"inbox\"): Push their health vector to the PGMQ bus queue `inbox_health_check` (`health-vector-push.sh`, POST `\u002Fapi\u002Fpgmq\u002Fsend`). The `orch-clean-health-queue` cron (every 10 min) drains the queue and persists each agent's latest vector to `~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json`; `orch-health-report.py` reads that file.\n\n### ⚠️ Two Orthogonal Monitoring Systems\n\nThe fleet runs **two independent monitoring systems** that measure different things. They can disagree — bus-offline does not mean health-down, and health-green does not mean bus-active. Understanding the distinction prevents confusion:\n\n| System | Script | What it measures | \"Offline\" means | Feed |\n|--------|--------|-----------------|-----------------|------|\n| **HTTP Health Vectors** | `orch-health-report.py`, `orch-fleet-watchdog.py` | Service-level health (resources, services, crons, nginx, ollama, mycortex, disk) | Service is down or degraded | `GET \u002Fhealth` endpoint per agent |\n| **Bus Liveness** | `orch-fleet-watchdog.py` | Agent bus activity — last time the agent produced a PGMQ audit log event | Agent hasn't touched the bus recently (may be sleeping, idle, or disconnected) | `bus.audit_log` in Postgres |\n\n**When they disagree:**\n- **Bus shows 🌙 offline but health is 🟢**: The agent is running and serving but hasn't processed any bus messages recently. Common for agents that only do local cron work or whose bus-processing crons run on a sparse schedule.\n- **Health shows 🔴 but bus shows ✅**: An agent has a service issue but can still post to the bus. The bus liveness check alone is insufficient for true health assessment.\n\n**Diagnosis procedure when an agent appears offline:**\n1. Check the bus audit log: `docker exec mycortex-postgres psql -U mycortex -d mycortex -t -c \"SELECT created_at, action FROM bus.audit_log WHERE agent_name='\u003Cname>' ORDER BY created_at DESC LIMIT 5;\"`\n2. Check the HTTP health endpoint via external URL (see Verification Protocol above)\n3. If bus shows offline but external URL shows healthy → agent is alive, just idle on the bus\n4. If both show offline → real problem\n\n❌ **Do this first:** Check the EXTERNAL HTTPS URL (Steps 1-2 of Verification Protocol), not the bus audit log. The bus is a secondary indicator — health is the primary one.\n\n### Per-Agent Port Allocation\n\nEach server agent gets a dedicated **external** port for nginx SSL termination.\nThe health-vector process binds to **127.0.0.1** (loopback) on the internal port\n(typically 8905) — nginx proxies `\u003Cexternal-port>\u002Fhealth` → `127.0.0.1:\u003Cinternal-port>`.\nThis prevents port conflicts and ensures TLS is handled at the proxy layer.\n\nExternal port mapping (agents poll the nginx SSL port):\n\n| Agent | External port (nginx SSL) | Internal port (health-vector) | Method |\n|-------|--------------------------|-------------------------------|--------|\n| Moses | 13007 | 8905 | HTTP poll via nginx proxy |\n| Gisu | 13007 | 8905 | HTTP poll via nginx proxy |\n| Kustos | 13007 | 8905 | HTTP poll via nginx proxy |\n| Joseph | 12007 | 8905 | HTTP poll via nginx proxy |\n| Esther | 14007 | 8905 | HTTP poll via nginx proxy |\n| Titus | — | — | Inbox push |\n\n> **PII note:** Actual domains are set via local override (`~\u002F.hermes\u002Fagent-registry.local.json`),\n> not committed to the public repo. See PITFALLS > Public repo PII.\n\n### Agent Registry health_method\n\nEach agent in `agent-registry.json` declares how Moses should poll it:\n\n```json\n\"moses\": {\n  \"health_method\": \"http\",\n  \"health_url\": \"http:\u002F\u002F127.0.0.1:13007\u002Fhealth\"\n},\n\"gisu\": {\n  \"health_method\": \"http\",\n  \"health_url\": \"https:\u002F\u002F\u003Cgisu-domain>:13007\u002Fhealth\"\n},\n\"titus\": {\n  \"health_method\": \"inbox\"\n}\n```\n\n**For PII safety**, the public repo stores port hints in description fields only.\nActual `health_url` values are configured via a local override file (see below).\n\n## Components\n\n### 1. `health-vector.py` — Agent-side health probe\n\nInstalled on every agent server. Two modes:\n\n```bash\n# Standalone (JSON to stdout)\npython3 health-vector.py\n\n# HTTP server (listens on \u003CPORT>)\npython3 health-vector.py --serve \u003CPORT>\n\n# Human-readable check\npython3 health-vector.py --check\n```\n\n**Output format:**\n```json\n{\"v\": [1, 1, 1, 1, 1, 1, 1, 1], \"h\": \"m\", \"t\": 1700000000}\n```\n\n**Hostname convention:** The `h` field should be a **single character** per agent\nfor compact display in health reports:\n| Agent | `h` value |\n|-------|-----------|\n| Moses | `\"m\"` |\n| Gisu | `\"g\"` |\n| Kustos | `\"k\"` |\n| Joseph | `\"j\"` |\n| Esther | `\"e\"` |\n| Titus | `\"t\"` |\n\nSet by `HEALTH_HOSTNAME` env var, falling back to the hostname's first character\n(`moses` → `m`, `gisu` → `g`, `titus` → `t`). Override per-machine if the\nhostname doesn't match the table:\n```python\nHOSTNAME = os.environ.get(\"HEALTH_HOSTNAME\") or os.uname().nodename.split(\".\")[0][:1].lower() or \"m\"\n```\nRun the service with `Environment=HEALTH_HOSTNAME=m` in the unit if the hostname\never diverges from the convention.\n\n**Bind address:** The server binds to **127.0.0.1** (loopback) when behind an\nnginx proxy to avoid port conflicts. nginx terminates TLS on `0.0.0.0`.\n```python\nserver = HTTPServer((\"127.0.0.1\", port), HealthHandler)  # not \"0.0.0.0\"\n```\n\nEach check function probes for the service:\n- **nginx**: `pgrep -x nginx`\n- **Ollama**: systemd\u002Flaunchd service, fallback to `pgrep ollama`\n- **mycortex**: systemd\u002Flaunchd service, fallback to `pgrep mycortex`\n- **Fleet Dashboard**: `curl http:\u002F\u002F127.0.0.1:8901\u002Fapi\u002Fhealth`\n- **Langfuse web\u002Fworker**: Docker container check\n- **Docker**: `dockerd` process or `\u002Fvar\u002Frun\u002Fdocker.sock`\n- **Hermes Gateway**: `pgrep -f \"gateway run\"`\n\n### `health-server.py` — RETIRED (removed commit `42fb8374`)\n\n> ⚠️ **This server is retired.** The FastAPI `health-server.py` was removed from\n> the repo in July 2026 (commit `42fb8374`); `health-vector.py` via\n> `health-vector.service` is the **only** deployed health server. The log-format\n> reference below is kept for reading HISTORICAL journal logs from before the\n> removal — it does not describe the current `health-vector.py` (which logs\n> minimally). Diagnostic procedure for the CURRENT server: check the\n> `health-vector.service` unit and its journal instead\n> (`systemctl --user status health-vector.service`,\n> `journalctl --user -u health-vector.service`).\n\nAs of July 2026, the retired `health-server.py` had structured logging with per-request timing.\nEvery request writes a line to stdout (captured by systemd journal) showing each\ncheck's duration:\n\n```\n2026-07-02T08:57:13.625 [INFO] COMPACT — m total=20.1s resources=0.0s services=0.1s crons=0.0s mycortex=20.0s\n2026-07-02T08:57:13.625 [WARNING] SLOW COMPACT HEALTH — m took 20.1s\n```\n\n**Log line reference:**\n\n| Prefix | Level | When | Example |\n|--------|-------|------|---------|\n| `STARTING` | INFO | Process starts | `server=moses agent=m port=8905 os=linux\u002F6.14.0 python=3.11.15` |\n| `CONFIG` | INFO | Startup | `_STARTUP_TS=1782950206 HOME=\u002Fhome\u002Fmoses` |\n| `HEALTH` | INFO | `\u002Fapi\u002Fv1\u002Fhealth` complete | `m total=0.3s resources=0.1s services=0.2s crons=0.0s mycortex=0.0s` |\n| `COMPACT` | INFO | `\u002Fhealth` or `\u002F` complete | `e total=20.1s resources=0.0s services=0.1s crons=0.0s mycortex=20.0s` |\n| `SLOW CHECK` | INFO | Any single check > 2s | `mycortex_sources took 4.5s` |\n| `SLOW COMPACT HEALTH` | WARN | Total > 5s | `m took 20.1s` |\n| `DEADLINE EXCEEDED` | WARN | mycortex check hit 20s cap | `mycortex_sources did not finish in 20.0s (20.0s elapsed)` |\n| `DEADLINE ERROR` | ERROR | mycortex check threw exception | `mycortex_sources failed after 3.2s: [Errno 12] Cannot allocate memory` |\n| `CHECK FAILED` | ERROR | Any check threw exception | `services crashed after 0.1s\\\\nTraceback...` |\n| `SHUTDOWN` | WARN | Process exiting (signal) | `received signal 15, exiting` |\n\n**mycortex cache TTL:** The mycortex_sources check caches its result for **900 seconds**\n(15 minutes) to avoid running the expensive `mycortex doctor --json` subprocess on\nevery request. The original 300s (5 min) TTL was bumped to reduce blocking\nfrequency. Baseline timing on a healthy system: `mycortex doctor --json` takes\n**~31 seconds** (only ~1s CPU — the rest is I\u002FO waiting on Ollama embeddings for\nsync freshness checks). The cache is invalidated after TTL expires, but the 20s\ndeadline ensures the endpoint never blocks more than 20s even when the cache is cold.\n\n**Process restart tracking:** The mycortex_sources check runs in a `ThreadPoolExecutor`\nwith a hard 20-second deadline. If exceeded, the endpoint returns a degraded response\n(`mycortex_sources_ok = -1`) instead of blocking the entire health endpoint. Check\nrestart count with:\n\n```bash\n# Total restarts since service started\nsystemctl --user show com.hermes.health-server.service -p NRestarts\n\n# Recent crashes with exit codes\njournalctl --user -u com.hermes.health-server.service --since \"1 hour ago\" --no-pager | grep -E \"STARTING|SHUTDOWN|CHECK FAILED|DEADLINE\"\n```\n\n**Key diagnostic procedure (RETIRED server, historical):** when the retired\nhealth endpoint timed out:\n\n1. Check if process is running: `systemctl --user status com.hermes.health-server.service` (historical — the CURRENT unit is `health-vector.service`)\n2. Read recent logs for DEADLINE EXCEEDED lines — they tell you which check is hanging\n3. Look for CHECK FAILED lines with tracebacks — crash evidence\n4. Check if OOM-killed: `dmesg | grep -i \"health-server\" | grep -i \"killed\"`\n5. Check if other services are destabilizing the system (see Ollama GPU crash pitfall below)\n\nSee `references\u002Fhealth-server-logging-diagnostics.md` for full details.\n\n### `health-vector.py` — Lightweight standalone probe\n\n### 2. `orch-health-report.py` — Orchestrator poller (HTTP + inbox state)\n\nRuns as a `no_agent` cron on Moses (`orch-health-report-weekday` hourly M-F 9-18,\n`orch-health-report-saturday`). Reads `agent-registry.json` to find agents and\ntheir `health_method`. (The former `orch-team-health.py` poller was **removed\nfrom the repo** in commit `69e3cf8e` — superseded by `orch-fleet-watchdog.py`\nfor state-change alerting; the hourly report is `orch-health-report.py`.)\n\n**Two fetch strategies:**\n\n| health_method | Strategy | Description |\n|---------------|----------|-------------|\n| `\"http\"` | HTTP GET | Poll `health_url` endpoint (e.g. `http:\u002F\u002Fagent:13007\u002F`) |\n| `\"inbox\"` | Bus state read | Read latest vector from `~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json` (persisted by `orch-clean-health-queue` every 10 min), fallback to a live `bus_read(\"inbox_health_check\")` |\n\n```python\ndef _fetch_http(url: str, auth: str = \"\") -> dict | None:\n    \"\"\"HTTP GET to a health-vector endpoint. Supports Basic Auth.\"\"\"\n    headers = {\"Accept\": \"application\u002Fjson\"}\n    if auth:\n        # Auth sent to inbox endpoint (not health endpoint — health has none)\n        headers[\"Authorization\"] = f\"Basic {encoded}\"\n    with urlopen(url, timeout=5, headers=headers) as resp:\n        return json.loads(resp.read().decode())\n```\n\n```python\ndef _fetch_inbox(agent_key: str) -> tuple[dict | None, str | None]:\n    \"\"\"Read the latest health ping for an inbox agent from persisted bus state.\n\n    Returns (parsed_health_data, ts_iso) or (None, None).\n    The ``orch-clean-health-queue`` cron drains ``inbox_health_check`` every\n    10 min and persists each agent's latest vector to\n    ``~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json`` — this reads that file\n    (with a live queue peek as fallback).\n    \"\"\"\n    state_file = Path.home() \u002F \".steadfaste-fleet\" \u002F \"state\" \u002F \"inbox-health-state.json\"\n    try:\n        if state_file.exists():\n            state = json.loads(state_file.read_text())\n            entry = state.get(agent_key)\n            if entry and isinstance(entry.get(\"vector\"), list):\n                return {\"v\": entry[\"vector\"]}, entry.get(\"ts\", \"\")\n    except (json.JSONDecodeError, OSError):\n        pass\n    return None, None\n```\n\n**Timeout:** 5 seconds per agent (was 3s — increased to handle transient SSL handshake jitter on external endpoints). Short enough that 5 unreachable agents don't block the poller (~25s total). Remote endpoints behind SSL\u002Fnginx can have brief DNS\u002FTCP jitter that exceeds 3s — 5s gives headroom for transient blips without hanging on real outages. If an agent doesn't respond in 5s, it's unreachable.\n\n**Inbox flow (client-only agents, current):** The retired file-inbox anchor-keep\npattern (keep oldest ping, DELETE newer ones via `api\u002Finbox`\u002F`api\u002Fdelete`) is\n**gone** — the `api\u002Finbox` endpoint no longer exists on the PGMQ bus server.\nToday:\n\n1. `health-vector-push.sh` POSTs the vector to the PGMQ queue `inbox_health_check` (`\u002Fapi\u002Fpgmq\u002Fsend`, subject `health`)\n2. `orch-clean-health-queue` (every 10 min) drains the queue, archives each ping, and persists the latest vector per agent to `~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json`\n3. `orch-health-report.py` reads that state file (fallback: live `bus_read` peek)\n\nNo accumulation: the queue is drained every 10 min and the state file holds at\nmost one entry per agent (always the latest ping).\n\n**Last-seen tracking:** The drain timestamp is recorded to\n`~\u002F.steadfaste-fleet\u002Fstate\u002Flast-seen.json` on each successful drain. This is used to\nsuppress Telegram alerts during laptop sleep — if no new pings arrive within a\nconfigurable window, the poller stays silent instead of alerting. Without this,\nevery lid-close would generate a 🔴 alert within 10 minutes.\n\n**State tracking:** Compares fingerprints between runs. Only alerts on **state transitions**:\n- Service was up (1) → now down (-1): alert with 🔴\n- Service was down (-1) → now up (1): resolution with ✅\n- Agent unreachable: alert with 🔴\n- Agent back online: resolution with ✅\n\n> **Watchdog pattern: silent = healthy.** When `orch-fleet-watchdog.py` produces empty stdout,\n> it means no state changed since last poll — everything is stable. Empty output is NOT\n> a sign of a broken cron. If you suspect the poller is broken, check\n> `~\u002F.steadfaste-fleet\u002Fstate\u002Fagent-health-data.json` for the latest snapshot.\n>\n> Similarly, if a client-only agent (Titus, `health_method: inbox`) shows as \"🔴 unreachable\"\n> in `orch-health-report.py`, check whether the agent has pushed health data recently\n> (`~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json` has an entry, and it's fresh).\n> For laptop agents, \"unreachable\" during sleep hours is **expected** — the\n> `last-seen.json` grace period suppresses alerts during sleep, but the health report will\n> still show the current state. See the \"Client-only agent unreachable (laptop sleep)\" pitfall below.\n\nThe bus connection is read from `~\u002Fsteadfaste-fleet\u002F.env`\n(`FLEET_BUS_URL` + `FLEET_BASIC_AUTH`, or Bearer `FLEET_BUS_TOKEN`). Each\nagent has their own credentials — never share the orchestrator's credentials\nwith peer agents. See `references\u002Finbox-health-format.md` for the push format,\nqueue details, and the code-duplication warning between the health scripts.\n\n**Health data** is written to `~\u002F.steadfaste-fleet\u002Fstate\u002Fagent-health-data.json`\nfor dashboard consumption.\n\n### 3. `health-vector-push.sh` — Client-only push script\n\nFor agents with no inbound access (`health_method=\"inbox\"`). Runs on a cron\u002Flaunchd schedule:\n\n```bash\n# Determines hostname, runs health-vector.py --check,\n# POSTs the JSON vector to the PGMQ bus queue inbox_health_check\n# (reads FLEET_BUS_URL + FLEET_BASIC_AUTH from ~\u002Fsteadfaste-fleet\u002F.env)\nbash ~\u002Fsteadfaste-fleet\u002Fops\u002Fscripts\u002Fhealth-vector-push.sh\n```\n\n**macOS launchd plist** at `docs\u002Ftemplates\u002Fcom.hermes.health-push.plist`:\n```xml\n\u003Cdict>\n    \u003Ckey>Label\u003C\u002Fkey>\n    \u003Cstring>com.hermes.health-push\u003C\u002Fstring>\n    \u003Ckey>ProgramArguments\u003C\u002Fkey>\n    \u003Carray>\n        \u003Cstring>\u002Fbin\u002Fbash\u003C\u002Fstring>\n        \u003Cstring>-c\u003C\u002Fstring>\n        \u003Cstring>exec \"$HOME\u002Fsteadfaste-fleet\u002Fops\u002Fscripts\u002Fhealth-vector-push.sh\"\u003C\u002Fstring>\n    \u003C\u002Farray>\n    \u003Ckey>EnvironmentVariables\u003C\u002Fkey>\n    \u003Cdict>\n        \u003Ckey>AGENT_NAME\u003C\u002Fkey>\n        \u003Cstring>titus\u003C\u002Fstring>\n        \u003Ckey>PATH\u003C\u002Fkey>\n        \u003Cstring>\u002Fopt\u002Fhomebrew\u002Fbin:\u002Fusr\u002Flocal\u002Fbin:\u002Fusr\u002Fbin:\u002Fbin\u003C\u002Fstring>\n    \u003C\u002Fdict>\n    \u003Ckey>StartInterval\u003C\u002Fkey>\n    \u003Cinteger>600\u003C\u002Finteger>  \u003C!-- 10 minutes -->\n    \u003Ckey>RunAtLoad\u003C\u002Fkey>\n    \u003Ctrue\u002F>\n    \u003Ckey>StandardOutPath\u003C\u002Fkey>\n    \u003Cstring>\u002Ftmp\u002Fcom.hermes.health-push.log\u003C\u002Fstring>\n    \u003Ckey>StandardErrorPath\u003C\u002Fkey>\n    \u003Cstring>\u002Ftmp\u002Fcom.hermes.health-push.err\u003C\u002Fstring>\n\u003C\u002Fdict>\n```\n\nRequires `FLEET_BUS_URL` + `FLEET_BASIC_AUTH` (or Bearer `FLEET_BUS_TOKEN`) in\n`~\u002Fsteadfaste-fleet\u002F.env` (the push script reads them from there).\n**Each client agent uses their OWN credentials** — never Moses' password.\n\n### 4. `agent-registry.json` — Agent configuration (public)\n\nLocated at `ops\u002Finstall\u002Fdeploy\u002Fagent-registry.template.json` (deployed to\n`~\u002F.steadfaste-fleet\u002Fstate\u002Fagent-registry.json`). The public repo version stores\nport hints in the `description` field but does NOT contain actual domain names:\n\n```json\n{\n  \"version\": 3,\n  \"agents\": {\n    \"moses\": {\n      \"name\": \"Moses\",\n      \"health_method\": \"http\",\n      \"health_url\": \"http:\u002F\u002F127.0.0.1:13007\u002Fhealth\"\n    },\n    \"gisu\": {\n      \"name\": \"Gisu\",\n      \"health_method\": \"http\",\n      \"description\": \"set health_url locally, port 13007\"\n    },\n    \"titus\": {\n      \"name\": \"Titus\",\n      \"platform\": \"macOS\",\n      \"health_method\": \"inbox\"\n    }\n  }\n}\n```\n\n### 5. `~\u002F.hermes\u002Fagent-registry.local.json` — Local override (private)\n\nActual domain URLs are configured on the orchestrator via a local override file\nin `~\u002F.hermes\u002F` (which is gitignored). The poller merges it on top of the public registry:\n\n```json\n{\n  \"version\": 3,\n  \"agents\": {\n    \"gisu\": {\n      \"health_url\": \"https:\u002F\u002F\u003Cactual-gisu-domain>:13007\u002Fhealth\",\n      \"accessible\": true\n    },\n    \"joseph\": {\n      \"health_url\": \"https:\u002F\u002F\u003Cactual-joseph-domain>:12007\u002Fhealth\",\n      \"accessible\": true\n    }\n  }\n}\n```\n\nThe override file only needs to specify the fields that differ from the public registry.\n`orch-fleet-watchdog.py` \u002F `orch-health-report.py` merge them automatically — no config change needed.\n\n### 6. `orch-health-report.py` — Health snapshot report (Telegram delivery)\n\nRuns as a `no_agent` cron producing a compact emoji-bar snapshot of every agent's\nhealth — designed for mobile Telegram display. Zero LLM tokens.\n\n**Silent-when-clean (2026-08-11, Luke directive):** the snapshot is delivered\nONLY when the fleet health signature changes — new issue, recovery, or first\nrun after deploy. Persistent identical state → empty stdout → no delivery.\nSignature is per-agent status + failing services, persisted to\n`~\u002F.steadfaste-fleet\u002Fstate\u002Fhealth-report-sig.json`. The `orch-fleet-watchdog.py`\n(5-min, transition-based) remains the primary alert channel; this hourly\nreport now mirrors it instead of pinging every hour.\n\n**Two health methods — same display code:**\n- `http` agents: `_fetch(url)` → parses `{\"v\": [...]}`\n- `inbox` agents: `_fetch_inbox_vector(agent_key)` → reads latest vector from\n  `~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json` (persisted by\n  `orch-clean-health-queue`) → parses `{\"v\": [...]}`\n\nBoth paths return the same vector format, so the emoji bar and failure listing code is shared.\n\n**Schedule:**\n| Cron | Schedule | Meaning |\n|------|----------|---------|\n| `orch-health-report-weekday` | `0 9-18 * * 1-5` | Every hour Mon-Fri 9AM–6PM KST |\n| `orch-health-report-saturday` | `0 11,17 * * 6` | Sat 11AM + 5PM KST |\n\n**Output format:**\n```\n━━━ Agent Health — Wed 10:12 UTC ━━━\n\nMoses ✅\n🟢🟢🟢🟢🟢🟢🟢🟢\n\nEsther ⚠️ 1 down\n🟢🟢🔴🟢🟢🟢🟢🟢\n  mycortex 🔴\n```\n\nThe script (`ops\u002Fscripts\u002Fagent\u002Forch-health-report.py`) reads the same agent registry\nwith local overrides as `orch-fleet-watchdog.py`, polls every agent's health\nendpoint (or reads the persisted inbox state for client-only agents), and outputs\ncompact markdown with emoji status bars.\n\n**Deployment:** Create crons with `no_agent=True` and `script=orch-health-report.py`.\nCopy the script to `~\u002F.hermes\u002Fscripts\u002F` first. See AGENTS.md for full setup.\n\n## Deployment\n\n### To install on a new server agent\n\n1. **Open the firewall port:**\n   ```bash\n   sudo ufw allow \u003CPORT>\u002Ftcp\n   ```\n   Replace `\u003CPORT>` with the agent's assigned port from the table above.\n\n2. **Install the health server as a systemd user service** (Linux) — the current\n   server is `health-vector.py`; the unit template ships in the repo:\n   ```bash\n   cp ~\u002Fsteadfaste-fleet\u002Fdocs\u002Ftemplates\u002Fhealth-vector.service ~\u002F.config\u002Fsystemd\u002Fuser\u002F\n   systemctl --user daemon-reload\n   systemctl --user enable --now health-vector.service\n   ```\n   (The retired FastAPI `health-server.py` \u002F `com.hermes.health-server.service`\n   was removed in commit `42fb8374` — do not install it.)\n\n   On macOS (launchd), run `health-vector.py --serve \u003Cport>` under a launchd\n   agent (no bundled plist; write your own with `ExecStart` pointing at\n   `~\u002Fsteadfaste-fleet\u002Fops\u002Fscripts\u002Fhealth\u002Fhealth-vector.py`).\n\n   The systemd unit uses `%h` (systemd home specifier) so it works across\n   different user accounts with zero hardcoded paths. It runs\n   `health-vector.py` with:\n   - `Restart=always`, `RestartSec=5`\n   - Logging to the systemd journal (`journalctl --user -u health-vector.service`)\n   - `Nice=10`, `IOSchedulingClass=idle` (never starves interactive work)\n\n   ⚠️ **After installing any new service, add it to `agent-service-recovery.py`'s `SERVICES` list.**\n   Otherwise a crash or SIGTERM leaves it dead until a human notices — the auto-recovery\n   script only restarts services in its watchlist.\n   See `references\u002Fservice-recovery-blind-spot.md` for the checklist and example.\n\n3. **Verify locally:**\n   ```bash\n   curl -s http:\u002F\u002F127.0.0.1:8905\u002Fhealth\n   # → {\"v\":[...], \"h\":\"moses\", \"t\":...}\n   ```\n\n4. **Set up nginx proxy** to terminate TLS and proxy `\u002Fhealth` to the internal health server:\n   ```nginx\n   server {\n       listen \u003CPORT> ssl;\n       location \u002Fhealth {\n           proxy_pass http:\u002F\u002F127.0.0.1:8905;\n       }\n   }\n   ```\n   Then verify externally with TLS:\n   ```bash\n   curl -sfk https:\u002F\u002F\u003Cagent-domain>:\u003CPORT>\u002Fhealth\n   ```\n\n5. **Set up bus config** for agent-to-agent messaging:\n   ```bash\n   # ~\u002Fsteadfaste-fleet\u002F.env\n   # Each agent uses their OWN credentials — ask Moses to create a htpasswd entry\n   FLEET_BUS_URL=\"https:\u002F\u002F\u003Cmoses-domain>:13004\"\n   FLEET_BASIC_AUTH=\"your-agent-name:\u003Cyour-password>\"\n   AGENT_NAME=\"your-agent-name\"\n   ```\n\n### To install on a client-only agent (macOS)\n\n1. **Set up bus config:**\n   ```ini\n   # ~\u002Fsteadfaste-fleet\u002F.env\n   FLEET_BUS_URL=\"https:\u002F\u002F\u003Cmoses-domain>:13004\"\n   FLEET_BASIC_AUTH=\"\u003Cyour-agent-name>:\u003Cyour-password>\"\n   AGENT_NAME=\"\u003Cyour-agent-name>\"\n   ```\n   `chmod 600 ~\u002Fsteadfaste-fleet\u002F.env`\n\n2. **Install the launchd push agent:**\n   ```bash\n   cp ~\u002Fsteadfaste-fleet\u002Fdocs\u002Ftemplates\u002Fcom.hermes.health-push.plist ~\u002FLibrary\u002FLaunchAgents\u002F\n   launchctl load ~\u002FLibrary\u002FLaunchAgents\u002Fcom.hermes.health-push.plist\n   ```\n\n3. **Test:**\n   ```bash\n   AGENT_NAME=titus bash ~\u002Fsteadfaste-fleet\u002Fops\u002Fscripts\u002Fhealth-vector-push.sh\n   ```\n   Silent = success. Errors go to `\u002Ftmp\u002Fcom.hermes.health-push.err`.\n\n## Diagnostic Procedure: \"Hourly report says 🔴 unreachable, manual run is green\"\n\n**Trigger:** The hourly `orch-health-report` (what lands in Telegram) marks an agent\n— usually Moses itself — 🔴 unreachable, but a manual `python3\n~\u002F.hermes\u002Fscripts\u002Forch-health-report.py` minutes later is green. Real outage vs\nmonitoring artifact? Run this sequence in order. (Discovered 2026-08-04: Moses\nred at 13:00\u002F14:00\u002F15:00, green at 15:03.)\n\n1. **Read the actual cron output** (not the chat paste):\n   `~\u002F.hermes\u002Fcron\u002Foutput\u002F\u003Cjob_id>\u002Flatest.md` — keyed by job ID, never name\n   (`cronjob action='list'` → `orch-health-report-weekday`). Check whether it\n   fails every run or just some (sporadic = timing; constant = config\u002Foutage).\n2. **Probe the external URL** — the ONLY health truth (localhost curls are not\n   evidence):\n   ```bash\n   curl -skS -w \"\\nHTTP=%{http_code} %{time_total}s\\n\" --max-time 15 https:\u002F\u002F\u003Cdomain>:\u003Cport>\u002Fhealth\n   ```\n3. **Measure latency repeatedly** — run 5+ probes. If responses are 2-10s, the\n   endpoint itself is slow → find the slow check:\n   ```bash\n   cd ~\u002Fsteadfaste-fleet\u002Fops\u002Fscripts\u002Fhealth && python3 - \u003C\u003C'EOF'\n   import time, importlib.util\n   spec = importlib.util.spec_from_file_location(\"hv\", \"health-vector.py\")\n   hv = importlib.util.module_from_spec(spec); spec.loader.exec_module(hv)\n   for fn in hv.CHECK_FUNCTIONS:\n       t0=time.time(); r=fn(); print(f\"{fn.__name__:\u003C28}{time.time()-t0:>7.3f}s -> {r}\")\n   EOF\n   ```\n   Any check > 1s is the culprit. As of 2026-08-04: `check_mycortex` shelled out\n   to `mycortex doctor --json` (~1.7s+) on EVERY request with no cache.\n4. **Check the health server journal for BrokenPipeError** — clients timing out\n   mid-write:\n   `journalctl --user -u health-vector.service --since \"1 hour ago\" --no-pager | grep -A6 \"line 448\"`\n   A traceback at `self.wfile.write(...)` = the poller gave up while the server\n   was still computing. Not a server crash — a symptom.\n5. **Check server concurrency**: `health-vector.py` uses `HTTPServer`\n   (single-threaded) — pollers (hourly report, fleet watchdogs, dashboard)\n   arriving within seconds at :00 serialize behind a slow request and queue\n   past their client timeouts. Fix: `ThreadingHTTPServer`.\n6. **Compare poller timeouts**: `grep -n TIMEOUT ops\u002Fscripts\u002Fagent\u002Forch-health-report.py`\n   vs `ops\u002Fscripts\u002Fagent\u002Forch-team-health.py`. (The former\n   `agent-health-monitor.py` was removed 2026-08-04 — deprecated,\n   superseded by `orch-fleet-watchdog.py`.) A 3s timeout against a\n   server that takes 2-9s under burst = guaranteed false red. Fleet guidance:\n   5s minimum for external SSL-terminated endpoints.\n7. **Fix pattern (all three layers, 2026-08-04 commit 03d95312):**\n   - slow check → short-TTL cache (60s; same pattern as the retired\n     health-server.py mycortex cache)\n   - single-threaded server → `ThreadingHTTPServer`\n   - short poller timeout → 3s → 5s\n8. **Verify through the scheduler, not manually**: `bash fleet-update.sh`\n   (deploy; purges gov locks — re-acquire), `systemctl --user restart\n   health-vector.service` (unit runs the repo file; running process needs a\n   restart to load new code), `cronjob action='run' job_id=\u003Cid>`, then confirm\n   the cron output shows ✅. Manual `python3` runs do NOT update the scheduler's\n   `last_status` or the doctor's run-evidence.\n\n**Rule of thumb:** sporadic \"unreachable\" for the self-poll only (other agents\ngreen) = timing\u002Fconcurrency on the local health server, not an outage. Check\nlatency distribution and server threading BEFORE touching the registry, nginx,\nor firewalls.\n\n## Health-Report Pitfall: Stale SERVICE_MAP\n\nThe orchestrator poller (`orch-health-report.py`) has a hardcoded `SERVICE_MAP` that maps vector indices to service names. Over time, if the agent-side health endpoint changes format (e.g. from 8-element `health-vector.py` to 9-element `health-server.py`), the poller's map becomes stale and misreports every vector.\n\n**Verification procedure when adding a new agent or after a health-endpoint update:**\n\n1. Poll the new\u002Fupdated endpoint directly: `curl -sS --max-time 5 https:\u002F\u002F\u003Cagent-url>\u002Fhealth`\n2. Count the vector elements — is it 8 or 9?\n3. Read the agent's `health-server.py`\u002F`health-vector.py` `_build_compact_health()` function to confirm the exact index-to-service mapping\n4. Update `SERVICE_MAP` in `orch-health-report.py` to match\n5. **Also update** `health_vector_map` in `agent-registry.json` — it must match the same order\n6. Run the poller once manually (`python3 ops\u002Fscripts\u002Fagent\u002Forch-health-report.py`) and verify the output shows the correct service names\n\n**Real example:** Remote agents run `health-server.py` which produces a 9-element vector `[resources, services, no_errored_crons, no_stale_crons, nginx, ollama, mycortex, disk_ok, mycortex_sources_ok]`. The poller had an 8-element map from the old `health-vector.py` template `[nginx, ollama, mycortex, cortex-dashboard, langfuse-web, langfuse-worker, docker, hermes-gateway]`, causing index 3 = -1 to report as \"cortex-dashboard down\" when it actually meant \"stale cron jobs\".\n\n---\n\n| Pitfall | Symptom | Fix |\n|---------|---------|------|\n| **Public repo PII** | Actual domain names committed to the public steadfaste-fleet repo | Use `~\u002F.hermes\u002Fagent-registry.local.json` for real URLs. The public repo stores port hints only. |\n| **Health URL uses internal address** | Poll passes locally but fails from orchestrator because the path bypasses nginx\u002FTLS. See `references\u002Fagent-registry-structure.md` for rules on external vs internal URLs, hostname vs host conventions, and example-file sync. | Always use the externally-reachable nginx SSL URL as `health_url`. Poll `https:\u002F\u002Fdomain:PORT\u002Fhealth` not `http:\u002F\u002F127.0.0.1:8905\u002Fhealth`. |\n| **Sharing orchestrator credentials** | Peer agents get Moses' htpasswd password. If one is compromised, all are. | Each agent gets their own htpasswd entry. `sudo htpasswd \u002Fetc\u002Fnginx\u002F.hermes-htpasswd \u003Cagent-name>` on Moses' server. |\n| **pgrep -x -f combined** | `_pgrep(\"gateway run\", full=True)` with `exact=True` default produces `pgrep -x -f \"gateway run\"` which requires exact command-line match (full string), not substring | Use `_pgrep(\"gateway run\", exact=False, full=True)` to produce `pgrep -f \"gateway run\"` for substring match |\n| **Agent registry uses dict key, not name** | Duplicate agent entries in health data — one with key from registry, another from fallback | Registry entries use the dict key (e.g. \"moses\") as the agent key, not the `name` field (e.g. \"Moses\"). The fallback check must compare against the same namespace. |\n| **Fleet Dashboard uses \"overall\" not \"healthy\"** | Legacy format handler reports healthy=False when services are actually up | Dashboard returns `{\"overall\": \"healthy\"}`, not `{\"healthy\": true}`. Check `data.get(\"overall\") == \"healthy\"`. |\n| **Compact format has different indices from legacy** | You see vector[3] = -1 and assume \"Fleet Dashboard\" is down. Actually it means \"stale cron jobs\" in the deployed compact format. | Always check the backend script serving the endpoint. `health-server.py` → compact 9-element format. `health-vector.py` → can serve either format; check CHECK_FUNCTIONS length. |\n| **`-1` means \"unhealthy\u002Fwarning\", not \"down\"** | The compact format has no `0` (n\u002Fa) — every index is always `1` or `-1`. A stale cron job (index 3) returns `-1` but the service is not \"down\" — it just hasn't run recently. See `references\u002Fschedule-aware-stale-detection.md` for how the stale threshold is computed from cron expressions (replaces hardcoded 24h). | Understand the semantics: `-1` may indicate a warning condition, not necessarily a service outage. |\n| **`-1` for uninstalled services** | Agents without a given binary (e.g. nginx on a macOS dev box) report `-1` because the check function only looks for the running process. Titus' nginx = -1 is misleading — it's not \"nginx is down\", it's \"nginx doesn't exist on this machine\" | Per-service checks (`check_nginx()`, `check_ollama()`, `check_mycortex()`) now use `shutil.which()` to detect if the binary exists. Returns `0` (not applicable) if not found. `check_services()` also returns `0` if no services are installed on the system (macOS fallback). See `references\u002Funinstalled-service-detection.md`. |\n| **External endpoint timeout sensitivity** | Agents behind nginx SSL (Moses 13007, Joseph 12007, Esther 14007) occasionally get marked \"unreachable\" even though they respond in ~0.1s — DNS\u002FTCP jitter on the HTTPS handshake spikes past the 3s timeout | Use 5s timeout for the orchestrator poller. 3s is fine for localhost (127.0.0.1) but external SSL-terminated endpoints need headroom. Polls every 10m — 5s per agent doesn't block the cycle. |\n| **Orchestrator self-poll must use external HTTPS URL** | When the orchestrator polls itself (Moses polls Moses), the code fallback defaults to `http:\u002F\u002F127.0.0.1:13007\u002F` — plain HTTP to a port nginx serves with `ssl` only. Nginx returns 400 \"plain HTTP sent to HTTPS\" → poll fails. | The self-poll URL MUST use the external HTTPS domain through nginx (e.g. `https:\u002F\u002Fdomain:13007\u002Fhealth`). Configure this via `agent-registry.local.json` — set Moses' `health_url` to the same external URL other agents use to reach Moses. The code fallback is a dev-only safety net that doesn't work when the nginx health block is SSL-only. Verify: `curl -sk https:\u002F\u002F$(hostname -f):13007\u002Fhealth` should succeed. If it doesn't, the registry URL is wrong or the nginx health block is misconfigured. |\n| **Long timeout on unreachable agents** | Poller takes 60+ seconds when 4+ agents are down | Short timeout (5s). The poller runs every 10 minutes. If an agent doesn't respond in 5s, it's unreachable. |\n| **Client-only agent unreachable (laptop sleep)** | Without the last-seen grace tracking, Moses alerts every 10 min when a laptop closes its lid. The `last-seen.json` grace period handles this naturally — pings stop during sleep, but alerts are suppressed within the window. See `docs\u002Fagent-onboarding.md` for the agent-side setup. |\n| **Agent has nginx running but is NOT a server** | If a client-only agent (Titus) has nginx installed for local dev, you might assume it's now reachable as a server | nginx on a dev machine does NOT make it a server. Client agents ALWAYS use `health_method: inbox` — never add a `health_url` for them, even if nginx is running. The presence of a web server does not imply reachability. Check `is_server` in the agent registry before setting up polling. |\n| **Agent has inbox on the same port as health** | Gisu had inbox on 13004, can't put health on the same port | Use a different port scheme. Moses\u002Finfra agents: 13007. Joseph: 12007. Esther: 14007. Avoid conflicts with existing inbox\u002Fdashboard ports. |\n| **Triple-sync requirement: SERVICE_MAP, CHECK_FUNCTIONS, --check labels** | You update the SERVICE_MAP docstring to 9 elements but the actual CHECK_FUNCTIONS list still returns 8 → the endpoint returns wrong vector length and downstream pollers misdiagnose every index | Always update all three: (1) SERVICE_MAP doc comment, (2) CHECK_FUNCTIONS list, (3) --check labels. Verify with `curl -s http:\u002F\u002F127.0.0.1:\u003CPORT>\u002F` and count elements. Run `python3 health-vector.py --check` to validate labels match. Commit to repo after testing. |\n| **Health queue backlog (drain stopped)** | Health pings accumulate in `inbox_health_check` (queue depth grows, `inbox_watch` returns MB-sized results). Means the `orch-clean-health-queue` cron stopped, or the push script targets the wrong queue. Check queue depth: `docker exec mycortex-postgres psql -U mycortex -d mycortex -t -c \"SELECT state, COUNT(*) FROM bus.messages WHERE queue_name='inbox_health_check' GROUP BY state;\"` and the cron's last run. |\n| **Consumer-producer sync: update consumer after verifying producer format, not before** | | You update the orchestrator health report script (consumer) to handle a format you assume Titus sends, without first verifying what he actually pushes | Pull the latest data from the producer first — read their actual format, test the endpoint, THEN update the consumer. Never update a consumer based on assumptions about the producer's format. The workflow is: (1) check what the producer sends, (2) write consumer to match, (3) verify both directions. |\n| **Dashboard `_find_pid()` does literal substring, not regex** | Service patterns like `legacy.*autopilot`, `[o]llama serve` use `.*` regex syntax, but `_find_pid()` does `if pattern_lower in line.lower()` — a literal substring check. The dot-star is never matched as a wildcard. | Use actual substrings that appear in `ps aux` output: `\"legacy autopilot\"` not `\"legacy.*autopilot\"`, `\"ollama\"` not `\"[o]llama serve\"`. The patterns in `server.py`'s `_health()` dict must match the literal process command line. Verify by grepping `ps aux` for the exact substring before adding. |\n| **Rich health-report format from inbox agents** | Titus pushes a JSON health report with services, issues, resources, uptime fields — not a compact `{\"v\": [...]}` vector. The `_parse_vector_body()` function in `orch-health-report.py` doesn't handle this format and returns `None`, marking the agent as unreachable. | `_parse_vector_body()` must detect `\"type\": \"health-report\"` in the JSON body and route to a rich-report parser (`_parse_rich_report()`) that converts the rich data to a vector while preserving metadata under a `_rich` key for `_build_structured_data()` to use. See `references\u002Frich-health-report-format.md`. |\n| **Health queue pings dropped before report reads them** | The hourly report finds no vector for an inbox agent because `orch-clean-health-queue` already drained and archived the pings (queue is transient). | The drain cron persists each agent's latest vector to `~\u002F.steadfaste-fleet\u002Fstate\u002Finbox-health-state.json`; the report reads that file (live queue peek is only a fallback). If Titus shows 🔴, check that file exists and is fresh — if missing, the drain cron is not running. |\n| **Inbox agents show 🔴 because report still calls retired `api\u002Finbox`** | Report queries `GET \u002Fapi\u002Finbox?...` which returns 404 on the PGMQ bus (endpoint removed in the inbox→PGMQ migration, commit `0f01556d`). Every inbox agent shows 🔴 unreachable despite healthy pushes; last-seen stays stale. | `_fetch_inbox_vector()` must read `inbox-health-state.json` (or `bus_read(\"inbox_health_check\")`), NOT `api\u002Finbox`. Fixed 2026-08-04 — see the implementation in `orch-health-report.py` and `orch-clean-health-queue.py`. |\n| **Endpoint path is `\u002Fhealth`, not bare `\u002F`** | Poller gets 404 on the root endpoint | The health-vector server serves at `GET \u002Fhealth`, not `GET \u002F`. `curl -s http:\u002F\u002F127.0.0.1:8905\u002Fhealth`, not `http:\u002F\u002F...:8905\u002F`. |\n| **Sharing untested URLs** | User calls you out for sending configs without verification | Test EVERY endpoint with `curl --max-time 5` from the external perspective before sharing with the user or peer agents. Do NOT only test from localhost — that only proves nginx is up locally. Check from the agent's perspective by reading the nginx access log for their IP or by using an external port checker. When an agent reports a connectivity issue, test ALL external endpoints (dashboard, langfuse, inbox, health) before diagnosing — a single endpoint being down vs all being down tells you whether it's a per-service or per-server\u002Fnetwork problem. |\n| **Old `com.hermes.health-server.service` vs current `health-vector.service`** | Docs mention a FastAPI `health-server.py` service on port 8905 — it was **removed from the repo** (July 2026). If `com.hermes.health-server.service` still exists on a machine it's an orphan from a pre-removal deploy. | The **current** canonical server is `health-vector.service` running `health-vector.py --serve 8905` (9-element compact vector, schedule-aware stale detection). If both units exist, disable the orphan: `systemctl --user disable --now com.hermes.health-server.service && systemctl --user enable --now health-vector.service`. Verify with `systemctl --user list-units | grep health`. |\n| **`check_services()` returns -1 when none are installed** | On macOS or agents without nginx\u002Follama\u002Fmycortex, `check_services()` iterates all key services and returns -1 if any is missing — even if the service isn't supposed to be there. | Fix: detect whether any key service is **installed** before checking. On Linux, check systemd unit existence. If none are present, return `0` (not applicable). On macOS, if no relevant processes are found via pgrep, return `0` instead of `-1`. |\n| **Ollama GPU crash cascade** | Health endpoint times out because Ollama crashes the GPU driver (Vulkan on old Intel HD 4000 iGPU, Ivy Bridge 2012). Ollama's vk::DeviceLostError destabilizes system resources, causing the health server to OOM-restart repeatedly (23+ restarts observed). The health vector looks broken but it's actually a cascading failure from Ollama. | Force Ollama to CPU-only on machines with old\u002Fincompatible GPUs: set OLLAMA_GPU_LAYER=false (or --cpu flag). On Ivy Bridge \u002F HD 4000 era hardware, the iGPU does not support Vulkan fully. Check restart count: systemctl --user show com.hermes.health-server.service -p NRestarts. Check ollama journal: journalctl --user -u ollama.service --since 1 hour ago --no-pager. If you see vk::DeviceLostError in ollama logs, the GPU is the root cause. |\n| **Orphan service: `Loaded: not-found` + `Active: active (running)`** | `systemctl --user status \u003Cservice>` shows `Loaded: not-found` but the service is still running. The unit file was deleted\u002Fremoved but the process from a previous load is alive. It will NOT auto-start on reboot. | Don't restart blindly — that fails because the unit file is missing. Find the source unit (check repo `ops\u002Finstall\u002F` or private repo) and re-install: `cp \u003Csource> ~\u002F.config\u002Fsystemd\u002Fuser\u002F && systemctl --user daemon-reload && systemctl --user restart \u003Cservice>`. If no source unit exists, the service was intentionally removed — stop the orphan cleanly. Cross-reference with `ss -tlnp | grep python3` to match ports to PIDs. |\n| **Bus liveness vs health vector disagreement** | Agent shows offline (bus audit log) but green (HTTP health vector). You investigate a non-issue. | Check both signals before deciding. Bus-offline + health-green = alive but idle. Bus-offline + health-down = real problem. See the Two Orthogonal Monitoring Systems section above. |\n| **Paused cron trips stale\u002Ferrored checks (FIXED 2026-07-31)** | A paused job (`enabled: false`, e.g. `orch-bus-forwarder-sync` paused for maintenance) keeps its old `last_run_at`. The stale check computes elapsed vs its schedule (e.g. `*\u002F2 * * * *`) and flags it permanently stale — health index 3 red forever. Same for a paused job with a frozen `last_status: error`. | `check_no_stale_crons()` and `check_no_errored_crons()` skip jobs with `enabled != true`. Paused jobs are intentionally not running — their frozen timestamps\u002Fstatuses must not drive the health vector. If health index 2 or 3 is red, first check whether the offender is paused before blaming the cron. |\n| **Bounded hour-range schedules flagged stale overnight (FIXED 2026-08-19, commit 90573ba9)** | Both orchestrators show index 3 = -1 (`no_stale_crons`) every night while a fresh local `python3 health-vector.py` run is all-green. Root cause: a cron with a bounded hour range (e.g. `0 8-22 * * *`, `orch-backlog-driver`) had its max legit silence computed as 1h (the `-` branch returned 3600), so after 2h of overnight silence it was flagged stale. The fix returns the overnight wrap gap `(24 - b + a) * 3600`. **Deploy lag:** the repo\u002Fdeployed script were already fixed but the long-lived `health-vector.service` process (running since Aug 13) held the old code in memory — a process restart is required after ANY health-vector.py change (`systemctl --user restart health-vector.service`); the file copy alone never reloads it. Verify via the EXTERNAL URL, not localhost. | After any `health-vector.py` edit: restart `health-vector.service` on the host AND its peer orchestrator (moses↔esther both run it). Diagnosis signature: external endpoint `-1` at index 3 while a fresh local script run returns `1` = stale in-memory code, not a real stale cron. Check `systemctl --user status health-vector.service` uptime vs the repo commit date. |\n| **Gateway restart interrupts in-flight LLM crons** | A gateway restart (\"Stopping gateway for restart...\", drain timeout at 180s) kills in-flight cron sessions. They are marked `interrupted` → `last_status: error` with NO output file written. Health index 2 goes red until each cron completes a new run. All affected crons share the exact same `last_run_at` timestamp (the interruption moment). | Not a cron bug — recovery is automatic on the next scheduled run. Verify: same-timestamp errors across several crons + gateway shutdown log lines at that moment. To confirm the crons re-ran, check `~\u002F.hermes\u002Flogs\u002Fagent.log` for new `cron_\u003Cjobid>_\u003Cnewer-timestamp>` sessions. If the red persists past the next run, then investigate the cron itself. |\n| **Errored cron feeds health vector index 2** | Health shows -1 at index 2 (no_errored_crons). A watchdog exited non-zero legitimately detecting a real problem (e.g. ClickHouse merge failures from langfuse-health-watchdog). | Read the failing cron output from cron output dir. Fix the underlying problem, not the health check. The watchdog and health vector are working correctly. |\n| **Persistent index-2 red on a REMOTE agent (2026-08-11)** | A remote agent's vector shows `no_errored_crons` red for hours with no transition — the fleet watchdog stays silent (transition-based) and, since 2026-08-11, the hourly report also stays silent on unchanged state. The red is invisible until it flips. | Diagnose proactively via fleet EXEC: `fleet send \u003Cagent> EXEC '{\"command\":\"fleet-doctor.py\",\"params\":[\"--quiet\"],\"timeout\":240,\"output_schema\":\"RAW\"}' --self-tested`, then poll `bus.archives` for `EXEC_RESULT` (~5.5 min). The doctor output names the errored cron (`⚠️ Cron status (\u003Cname>) — last run: error`). Fix in the repo, then `UPDATE_REQUEST` the agent. Note: a remote agent N commits behind also fails updates until it pulls — check `git_sha_after` in the UPDATE_RESULT, not just `success` (see fleet-commands skill). |\n| **Sporadic self-poll \"unreachable\" while manual run is green (FIXED 2026-08-04)** | Hourly report marks Moses 🔴 unreachable at :00 while a manual run minutes later is green. Root cause chain: `check_mycortex` runs `mycortex doctor --json` (~1.7s+) on every request with no cache → single-threaded `HTTPServer` serializes the :00 poller burst → 2-9.6s wall times → report's 3s timeout fires → BrokenPipeError in the server journal. Other agents stay green because their endpoints are on other hosts. | Three-layer fix (commit 03d95312): cache the slow check (60s TTL), `ThreadingHTTPServer`, poller `TIMEOUT` 3→5. Diagnostic steps in the \"Diagnostic Procedure\" section above. |\n| **Laptop agent shows green forever after it stops pushing (FIXED 2026-08-04)** | Inbox-method agent (Titus) stops pushing health pings, but the hourly report keeps showing ✅ green indefinitely. `_fetch_inbox_vector` read the persisted vector from `inbox-health-state.json` unconditionally — no staleness check — so the 30-min grace \u002F 🔴 unreachable logic never engaged. (Found 2026-08-04: Titus pushed until 18:48 KST then stopped; report still showed 9 greens at 19:20.) | Freshness gate in the state-file read (commit 16400583): if the persisted vector's `ts` is older than `LAPTOP_GRACE_MINUTES`, return None so the caller applies the offline\u002Funreachable path. A laptop agent that is not pushing must show unavailable — never stale green. |",{"name":5,"author":24,"version":25,"platforms":26,"description":7},"Steadfaste Fleet","3.5.0",[27,28],"macos","linux","main","9dc0e92c5fa81d4db5292b205716e8ea0c00d10e","skills\u002Fdevops\u002Fagent-health-monitoring",1,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet","steadfaste.com","https:\u002F\u002Fgithub.com\u002Flukemcqueen","AI Architect | Building Hermes Cortex: governed multi-agent AI for autonomous software engineering | Enterprise Tech Consultant","2026-11-14 22:33:34",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add lukemcqueen\u002Fsteadfaste-fleet --skill agent-health-monitoring",{"tool":44,"command":45},"bunx","bunx skills add lukemcqueen\u002Fsteadfaste-fleet --skill agent-health-monitoring",{"tool":47,"command":48},"pnpm","pnpm dlx skills add lukemcqueen\u002Fsteadfaste-fleet --skill agent-health-monitoring","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002FSKILL.md",true,[52,58,62,66,70,74,78,82,86,90,94,98,102,106],{"path":53,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":56,"sourceHtmlUrl":57},"references\u002Fagent-registry-structure.md","REFERENCE","参考文档",3163,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Fagent-registry-structure.md",{"path":59,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":60,"sourceHtmlUrl":61},"references\u002Fcompact-health-vector-format.md",3289,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Fcompact-health-vector-format.md",{"path":63,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002Fhealth-pulse-inbox-flood-diagnosis.md",4344,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Fhealth-pulse-inbox-flood-diagnosis.md",{"path":67,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":68,"sourceHtmlUrl":69},"references\u002Fhealth-server-logging-diagnostics.md",6334,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Fhealth-server-logging-diagnostics.md",{"path":71,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fhealth-vector-schema-migration.md",4072,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Fhealth-vector-schema-migration.md",{"path":75,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Finbox-health-format.md",3571,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Finbox-health-format.md",{"path":79,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":80,"sourceHtmlUrl":81},"references\u002Flangfuse-clickhouse-merge-diagnosis.md",5809,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Flangfuse-clickhouse-merge-diagnosis.md",{"path":83,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":84,"sourceHtmlUrl":85},"references\u002Fpgrep-flags.md",2062,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Fpgrep-flags.md",{"path":87,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":88,"sourceHtmlUrl":89},"references\u002Fport-allocation.md",2414,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Fport-allocation.md",{"path":91,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":92,"sourceHtmlUrl":93},"references\u002Frich-health-report-format.md",5573,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Frich-health-report-format.md",{"path":95,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":96,"sourceHtmlUrl":97},"references\u002Fschedule-aware-stale-detection.md",2829,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Fschedule-aware-stale-detection.md",{"path":99,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":100,"sourceHtmlUrl":101},"references\u002Fservice-recovery-blind-spot.md",1843,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Fservice-recovery-blind-spot.md",{"path":103,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":104,"sourceHtmlUrl":105},"references\u002Funinstalled-service-detection.md",1956,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Funinstalled-service-detection.md",{"path":107,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":108,"sourceHtmlUrl":109},"references\u002Fwatchdog-vs-crash-semantics.md",3572,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fagent-health-monitoring\u002Freferences\u002Fwatchdog-vs-crash-semantics.md",[111,119,126,133,140,147],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":118},"01M7DXY4G8NSVB59K8B6S2AQNP","macbook-linux-maintenance","Legacy MacBook Linux fixes: GPU wedge, reboot hang, thermal.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fmacbook-linux-maintenance\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":118},"01M7DXXYJCXFJ3TGB84ZQ8KFE6","governance-regression-triage","Triage a host's governance issues: what changed.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fgovernance-regression-triage\u002FSKILL.md",[],[],{"skillNo":127,"name":128,"nameZh":6,"description":129,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":130,"categories":131,"keywords":132,"publishedAt":118},"01M7DXXSAP1G8FDRJAMXQGBBMK","enforcement-immutability","Use when enforcement files lose their immutable flag.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fenforcement-immutability\u002FSKILL.md",[],[],{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":118},"01M78SSDQVRYX64Y16X32TC0NS","steadfaste-fleet-repo-deploy","Use when committing to the steadfaste-fleet repo.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fsteadfaste-fleet-repo-deploy\u002FSKILL.md",[],[],{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":118},"01M78SS928F3R2RJAYVW4E30CE","steadfaste-fleet-maintenance","Maintain an installed Steadfaste Fleet instance — update both the upstream Hermes Agent and the fleet repo layer, merge diverged histories, sync skills safely, and troubleshoot common issues. Covers the dual-update workflow (hermes update + fleet-update.sh), encrypted brain data backup, mycortex import, and recovery techniques.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fsteadfaste-fleet-maintenance\u002FSKILL.md",[],[],{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":153,"publishedAt":118},"01M78SP1CHW0T0BWE5ZT6JBPX8","fleet-preflight","DEPRECATED alias — merged into survey-before-action (2026-08-20). Load survey-before-action instead; its \"Repo-Specific Pre-Flight\" section covers git search, Hermes boundary, and deployment verification.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Ffleet-preflight\u002FSKILL.md",[],[]]