Skip to content

Restart the supervisor when its own code changes - #21

Merged
Castrozan merged 1 commit into
mainfrom
supervisor-refresh-on-code-change
Aug 25, 2026
Merged

Restart the supervisor when its own code changes#21
Castrozan merged 1 commit into
mainfrom
supervisor-refresh-on-code-change

Conversation

@Castrozan

Copy link
Copy Markdown
Owner

What was wrong

clawde.service carries X-RestartIfChanged = false, so home-manager rewrites the unit file on every rebuild and never restarts the running process. New supervisor code stays dormant until a human restarts it or the machine reboots, and nothing reports that.

Live evidence on chise: the supervisor had been running since Aug 22 21:05 across generations 1618 to 1626. Its clawde-service store path and its specification file had both been garbage-collected. Every rebuild in that window reported success. The sidecar supersession fix from v0.12.7 sat in the store, deployed and dormant, in the very process meant to run it.

What changed

A home activation runs clawde-supervisor-refresh, which compares the running supervisor's command line against the one this generation deploys and restarts only on a mismatch. A healthy supervisor already on the current generation is still never disturbed, which is what the flag was protecting.

The deployed command is read from a writeText file rather than passed as an argument: an argument carrying clawde-service.py --specification-file would make pgrep -f match the checker itself, the same self-match trap the bridge reconcile pattern documents. The checker also filters its own pid.

clawdeServiceRestartCommand on linux now runs daemon-reload before restart, so a restart cannot start the unit file the activation just replaced.

Verification

  • All five flake checks green: unit-tests, formatting, lint, discord-transport-eval, global-runtime-stays-universal
  • 7 new tests, including the self-match guard and both branches of main

The unit carries `X-RestartIfChanged = false` so a rebuild never disturbs
a healthy supervisor. The cost was never stated: home-manager rewrites the
unit file and leaves the old process running, so new supervisor code stays
dormant until someone restarts it by hand or reboots.
On chise that ran for three days. The supervisor was executing a
clawde-service store path that had already been garbage-collected, with a
specification file that no longer existed, while every rebuild reported
success. The sidecar supersession fix shipped in v0.12.7 was live in the
store and dormant in the process that was supposed to run it.
An activation now compares the running supervisor's command line against
the one this generation deploys and restarts only on a mismatch, so a
healthy supervisor is still never disturbed. The deployed command is read
from a file rather than passed as an argument, because an argument
carrying `clawde-service.py --specification-file` would make the check
match itself the way a bridge pgrep does.
Agent-Machine: kira
Agent-Resume: claude --resume efee1316-8d94-438e-951e-e9c978626531
@Castrozan
Castrozan merged commit 01b799f into mainAug 25, 2026
3 checks passed
Sign up for freeto 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

@Castrozan