ADR 0032: A stable wats path in the agent tools, and repairing stale ones
Status: Accepted (2026-10-22). Ships in 0.4.4.
Context
Section titled “Context”wats setup <tool> --mcp writes the path of the running wats into the
agent tools’ configs: the wats MCP server of Claude Code
(~/.claude.json), Codex (~/.codex/config.toml), OpenClaw (through
openclaw mcp set, ADR 0017) and Mistral Vibe (~/.vibe/config.toml),
OpenClaw’s wats-agent entry, and the wats notify --hook session hooks
of Claude Code (~/.claude/settings.json) and Codex. The node also writes
it into each agent run’s MCP config.
Up to 0.4.3 that path had its symlinks resolved. For a Homebrew install it
was the versioned Cellar directory, /opt/homebrew/Cellar/wats/0.4.3/bin/wats.
brew upgrade wats followed by brew cleanup, which Homebrew also runs by
itself after upgrades, removes that directory. Every agent tool then fails
to start wats, and its sessions lose the swarm without saying so.
Decision
Section titled “Decision”- Write a stable path (
update::stable_exe): for a Homebrew install, Homebrew’s link (<prefix>/bin/wats, else<prefix>/opt/wats/bin/wats) when it leads to the running binary; it is found from the Cellar path, without runningbrew. Otherwise, the path the user started wats by (argv[0], or the PATH entry it names) when it leads to the running binary. Otherwise, the binary itself, as before: install.sh’s copy in~/.local/binis no symlink and is stable as it is. The background node is respawned through Homebrew’s link when the running binary is gone. - Check wats’s own entries at each start of the node and in
wats status. An entry is stale when its wats path no longer exists, or is in a versioned Cellar directory (gone at the next cleanup). - The node’s start is the only automatic repair.
wats statusonly checks and warns: its line says that the node repairs the entry at its next start, or gives thewats setupcommand. - Repair only the path of wats’s own entry, and only to Homebrew’s link
of the same prefix, when that link exists and leads into the Cellar
of wats. Only the bytes of that one string change: JSON is edited in
place, TOML through
toml_edit, and OpenClaw’s config only throughopenclaw mcp set, with the entryopenclaw mcp showprinted. One line in the node’s log names the file fixed.- A backup first:
<file>.wats-repair.bak-<UTC timestamp>, with the file’s mode. None when the newest one already holds the same content, and only the newest 3 are kept. Setup’s own backups (<file>.bak-…) are never touched. - An atomic write: a temporary file next to the target (same mode,
and owner when allowed), synced, then renamed over it. A symlinked
dotfile is resolved first, so that the target is replaced, not the
link. Just before the rename the file is read again: when it changed
(Claude Code rewrites
~/.claude.jsonoften), the edit is redone once on the fresh content; a second change gives up with a warning. - A bounded OpenClaw: each
openclawcommand is killed after 3 seconds, so a hung OpenClaw holds up neither the node’s exit norwats status.wats statusnever runs it: it reads openclaw.json only.
- A backup first:
- Otherwise, warn with the command that fixes it (
wats setup <tool> --mcp, with--dirwhen the entry has one): in the log, inwats status, and in the MCPstatustool (registrations). Running setup again always fixes it, since it writes the stable path.
Only a node on the real network checks. Hermetic and loopback modes
(tests, local demos) never read the tools’ configs, nor does a wats run by
cargo test or cargo run of wats itself (CARGO_PKG_NAME=wats), unless
WATS_CHECK_REGISTRATIONS=1 asks it to, with a throwaway HOME.
Why the repair is this narrow
Section titled “Why the repair is this narrow”- The file is the user’s, and other tools write it. Claude Code
rewrites
~/.claude.jsonall the time, and the user edits the others. Rewriting one string we wrote ourselves is the smallest change that brings wats back. Re-running setup could change more: the profile, the scope, the hooks the user removed. That stays the user’s call. - Homebrew’s link is the same install, one version on. A gone path outside Homebrew (a moved or deleted install, a build tree) gives no safe replacement. The running binary may be a development build, or another install, so writing it there could point the user’s tools at the wrong wats. A warning with the exact command is the honest answer.
- Entries that are not ours are never touched, even when they run the
same stale path. Only the
watsandwats-agentMCP entries and the hooks withnotify --hookare ours. - Secrets are not round-tripped blindly. An OpenClaw entry is set
again only when
openclaw mcp showshows no masked value anywhere in it (***,<redacted>…), and thewats-agententry only when it shows the very runner token wats keeps. Otherwise wats warns.
Consequences
Section titled “Consequences”-
Users who registered with 0.4.3 or older are repaired at the first start of a 0.4.4 node;
wats statussays so before. Until then, after abrew cleanup,wats setup <tool> --mcpfixes it. -
Codex may ask to review a repaired hook again (
/hooks): the notice says so. -
Follow-ups, not covered yet: project-scoped Claude Code entries (a project’s
.mcp.jsonand.claude/settings.json, and the local scope,projects.*in~/.claude.json), project-level Vibe configs, and OpenClaw configs at a path other than the default or theOPENCLAW_*variables. Setup fixes those. -
Follow-up: OpenCode’s
mcp.watsentry in its global config ($XDG_CONFIG_HOME/opencode/opencode.json(c), ADR 0031) is not checked yet. It is new in 0.4.4 and written withupdate::stable_exe()from the start, so no release left a Cellar path there. Adding it is not a small change, for two reasons:- The file is often JSONC. Comments and trailing commas defeat the in-place JSON rewrite this check uses.
- ADR 0031 says wats never edits OpenCode’s config itself. A repair
would go through
opencode mcp add, as OpenClaw’s goes throughopenclaw mcp set, with its own timeouts and a version check.
Until then,
wats setup opencode --mcpfixes it.
From wats v0.5.11 · source on GitHub
We are the swarm.