Skip to content

Incident log: what failed, where, when and why - #6

Merged
skmp merged 4 commits into
mainfrom
skmp/incident-log
Nov 27, 2026
Merged

skmp merged 4 commits into
mainfrom
skmp/incident-log

Conversation

@skmp

@skmp skmp commented Nov 27, 2026

Copy link
Copy Markdown
Member

The owner asked on 2026-11-27 for an accountability log of everything that goes wrong (machine, time, what failed, why), after the wsl machine went down unseen: the Windows disk C: filled up, WSL's ext4 root remounted read-only, and Claude Code exited with "Bus error (core dumped)". All the hub had was list calls on wsl failing as refused_by_policy / tmux_failed from 10:57 UTC, then an agent disconnect at 12:03:48 UTC and a reconnect at 12:03:58 UTC.

Design (details in docs/SWITCHBOARD.md "Incident log", decisions in docs/DESIGN.md)

  • The log: stateDir/incidents.jsonl, mode 0600, append-only. An incident is written when it opens and again, with the same id, when it closes; a reader keeps the last line of each id. Fields: id, start/end (UTC) plus local times and zone (incidents.timeZone or the hub's zone), duration, machine (or hub), component, stable code, what, why, effect, recovery, count, source (auto/owner/cli). It rotates by size (default 1 MB x 3 files) and carries the open incidents into the new file. Appends hold a file lock, so the CLI can write next to the hub. Lines are at most 8 KB. No pane text, prompts, tokens, paths or machine stderr: only fixed hub texts, numbers, config machine names and the owner's own words, which are redacted and clipped.
  • Automatic incidents: there is one incident per (machine, component, code). Repeats only bump a counter in memory. A success marks the incident recovered, and it closes after settleSeconds (120) with no new failure, so a flapping link stays one incident (two lines). New automatic incidents are capped at 30 per hour; anything past that is counted in one incident_flood. Incidents left open by an earlier run are adopted at the next start. Triggers:
    • every dispatcher call, through ObservedTransport: tmux, dispatcher (bad_policy, busy, missing, bad response, crashed), and ssh/transport failures and timeouts
    • an agent link closing (unless replaced or closed by the hub's own stop), closed on reconnect with the gap ("it connected again after 10 seconds")
    • relay socket and connection problems
    • summariser failures (auth_failed for a 401 or login error, timeout, error)
    • tool exceptions (recorded by type only)
    • an unclean hub stop (a hub-alive.json marker left behind)
  • Error mapping fix: tmux_failed is now the transport error remote_failed, not refused_by_policy. Spoken: "wsl answered, but tmux failed there."
  • Machine health: dispatcher 0.9.0 adds a read-only health verb. It needs no opt-in, uses the stdlib only and runs on Python 3.8. It reports free/total bytes and ST_RDONLY for /, $HOME and the Claude Code home. On WSL it also reports /mnt/c when mounted (statvfs only, in a daemon thread with a 3 s limit, with only one probe in flight at a time). It also reports load, memory and uptime, all by fixed labels, never paths. The hub polls every 300 s by default, and also when an agent connects, and checks its own state dir the same way. It opens incidents for free space under 5 GB or 5 %, any read-only file system, and available memory under 200 MB. Each closes only once the value is back past the limit by a margin (10 % more space and 1 point more percent, 20 % more memory). Example why: "the Windows disk C: has 57 GB free of 1.9 TB (97 % used): WSL's disk image usually lives there, and when that disk fills, WSL's root file system goes read-only and programs crash (inside WSL the root still shows free space)". Dispatchers older than 0.9.0 are polled with version instead.
  • Owner side:
    • MCP tool incidents(machine?, since?, open_only?, details?), read-only, with a short spoken summary
    • MCP tool incident_note(machine, what, why?), which records the owner's words as a note and does nothing else
    • CLI voice-coding-mcp incidents [list|add|close]
    • list_remote_sessions / remote_status add one clause for an open incident on that machine, without repeating a failure the answer already states
    • optional incidents.notify pushes through notify.url

New config: incidents.{enabled,timeZone,settleSeconds,maxKilobytes,keepFiles,notify,health.{intervalSeconds,minFreeGigabytes,minFreePercent,minMemoryMegabytes}} (docs/REFERENCE.md). Docs: SWITCHBOARD.md, REFERENCE.md, DESIGN.md, SETUP-AGENTS.md (dispatcher update), SETUP-WSL.md (owner guide paragraph and troubleshooting).

Tests

uv sync --locked, ruff check, ruff format --check and mypy --strict src tests are clean. pytest: 1850 passed, 9 skipped (full run; the one failure in that run was tests/test_cli.py listing the commands, now fixed, plus test_status_of_a_menu_with_twelve_options, a timing flake under a load average of 17 that passes 3 out of 3 runs alone). The new file is tests/remote/test_incidents.py (39 tests). It covers:

  • the log format, UTC and local times, mode 0600, cleaning, redaction and bounds, unreadable lines, rotation keeping open incidents, and a refused write
  • repeats, the settle time, the flood cap, disabled mode and adoption
  • the tmux failure open/close, ordinary refusals opening nothing, and every failure mapping
  • privacy: no machine text reaches the log
  • the fixed error mapping
  • link flap debounce (20 flaps give one incident and two lines) and today's 10 s gap
  • relay events, unclean stop, the summariser 401 detection, and the tool exception wrapper
  • health thresholds with a WSL-like fake (C: at 57 GB of 1.9 TB, a read-only root, sameAs) and margins
  • the poller, including the fallback for old dispatchers
  • the dispatcher verb with a fake /proc (WSL detection, the mount check, the read-only flag, a hanging drive timing out, no paths in the output)
  • the tools (spoken report, note, list/status clause) and the CLI (add/list/json/close/errors)

Existing tests were updated for the version and verbs, the tool list snapshot and the tool count.

Deploy

  1. Hub: update the checkout to this commit, uv sync --locked, restart the hub. The defaults are on. Health polls start at once and do nothing harmful against old dispatchers. Optionally set incidents.timeZone to Europe/Athens (a VPS hub is usually on UTC) and incidents.notify.
  2. Machines: install switchboard-remote 0.9.0 (and switchboard-connect, whose version moves with it) from the owner's own verified copy, as in SETUP-AGENTS.md "Updating the dispatcher". Restart switchboard-connect on agent machines. No forced-command or flag change is needed. remote-check should show 0.9.0 with health.
  3. Record the first entry (below).

First entry (run on the hub after deploy, as the hub user)

sudo voice-coding-mcp incidents add \
  --machine wsl --component machine_health --source owner \
  --start 2026-11-27T10:57:15Z --end 2026-11-27T12:03:58Z \
  --what "machine down: WSL root read-only, Claude Code Bus error (core dumped)" \
  --why "the Windows host disk C: filled up; WSL's ext4 root remounted read-only (errors=remount-ro)" \
  --effect "wsl's sessions could not be listed or read (tmux failed from 10:57 UTC), then wsl was disconnected" \
  --recovery "WSL restarted 14:03 Athens time; C: still at 97 % afterwards, 44 GB of build output removed"

(On a Linux or WSL hub with the dedicated user, use sudo -H -u switchboard <venv>/bin/voice-coding-mcp incidents add ... --config <config> instead.) voice-coding-mcp incidents --details shows it.

Open questions

  • The WSL disk image may live on a drive other than C:. Only /mnt/c is probed; a --host-drive dispatcher option or a hub setting could name it.
  • A laptop that sleeps loses its heartbeat every night, which opens link_down incidents. Should those open only after a grace time?
  • Health polls of ssh machines cost one ssh login every 5 minutes. Should ssh machines be polled less often?
  • A machine named hub is allowed with a warning. Should the name be reserved instead? That would break an existing config with that name.
  • Rebase note: this PR adds health at the end of VERBS (dispatcher and protocol), "health" to READ_ONLY_VERBS, and bumps the dispatcher and connector to 0.9.0. After Media attachments: images, audio and video from a machine's outbox #5 (0.7.0) and the clear-input PR (0.8.0), keep their verbs, append health, and keep 0.9.0; regenerate tests/fixtures/tool_list.json and the tool count in tests/test_mcp.py / tests/test_e2e.py.

🤖 Generated with Claude Code

https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh

skmp and others added 4 commits November 27, 2026 14:46
The dispatcher's tmux_failed is something failing on the machine, but the
hub mapped every dispatcher error code to refused_by_policy, so the journal
and the spoken answers said the request was refused ("switchboard-remote
refused the request") when tmux there had failed. tmux_failed now maps to
the new transport error remote_failed with the code in detail, spoken as
"wsl answered, but tmux failed there." Sends keep their not_sent outcome.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh
`health` reports, by fixed label and never by path, the free and total
bytes and the read-only flag (statvfs ST_RDONLY) of /, $HOME and the
Claude Code home; on WSL (Microsoft in the kernel release) also of the
Windows drive at /mnt/c when it is mounted, probed in a daemon thread with
a 3 s limit because DrvFs goes through the Windows host. Plus load,
available memory and uptime. No arguments, no opt-in: it is allowed under
the normal policy like list. Standard library only, Python 3.8.

Inside WSL the root's free space does not show the Windows disk filling,
which is how the WSL root went read-only without warning.

The connector's version moves with the dispatcher's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh
stateDir/incidents.jsonl (0600, append-only, rotated by size with the open
incidents carried over, appends under incidents.lock so the CLI can write
next to the hub): one line when an incident opens and one when it closes,
with UTC and local times, machine (or hub), component, a stable code,
what, why, effect, recovery, a repeat count and the source (auto, owner,
cli). Never pane text, prompts, tokens or a machine's error text.

Automatic incidents (IncidentTracker): every dispatcher call goes through
ObservedTransport (tmux failures, bad policy, busy, missing or crashed
dispatcher, ssh and transport failures and timeouts); agent links that
close without being replaced or stopped by the hub; relay socket and
connection problems; summariser failures (a refused login is auth_failed);
tool exceptions (by type only); an unclean hub stop (a hub-alive.json
marker left behind). Repeats only count; a success closes an incident only
after incidents.settleSeconds without the failure, so a flapping link stays
one incident; at most 30 new automatic incidents per hour, the rest are
counted in one incident_flood. Open ones are adopted at the next start.

Machine health (HealthPoller): the dispatcher's health verb every
incidents.health.intervalSeconds (default 300, also when an agent machine
connects) and the hub's own state directory; incidents for a file system
under minFreeGigabytes or minFreePercent, any read-only file system and
low memory, closing with a margin. On WSL the Windows disk counts, with
the reason spoken: WSL's disk image lives there and goes read-only when it
fills. A dispatcher before 0.9.0 is polled with version instead.

Owner side: the incidents tool (spoken summary for a period, open ones
always), incident_note (records the owner's words as a note), the CLI
voice-coding-mcp incidents [list|add|close], one short clause about an open
incident in list_remote_sessions and remote_status, and optional pushes
with incidents.notify.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh
SWITCHBOARD.md gets the "Incident log" section (file, automatic
incidents, machine health, owner tools, open questions), the incidents
config table, the health verb and the remote_failed mapping; DESIGN.md
records the decisions; REFERENCE.md the config keys, the incidents CLI
and the two tools; SETUP-AGENTS.md how to update the dispatcher to 0.9.0;
SETUP-WSL.md a short owner guide paragraph and a troubleshooting line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant