Host sleep and the awake Mac — VUH-1461
Clankie now says when this Mac may sleep, and offers an always-on option. The
code is proven with fakes. Real sleep/wake recovery is not proven yet: it is a
human check, and the steps are below. No power setting was changed, no caffeinate
was started, and the Mac was never put to sleep while building this.
2026-10-17 (VUH-2393): keep-awake is now on by default for a self-hosted Mac.
On this Mac, a scratch launcher with no stored choice started caffeinate -s
(clankie status: "holding this Mac awake while plugged in"), pmset -g assertions
showed its PreventSystemSleep on AC power, crash recovery restarted it after it
was killed, and clankie awake off stored false and stopped it. Real sleep, wake
and lid-closed behaviour are still unproven: the live Mac was not put to sleep, and
Amphetamine was holding it awake throughout. The steps below remain the human check.
Evidence (fakes)
- Protocol: 14 tests.
pmsetparsing on the real output shapes (-g batt,-g customwheredisplaysleepanddisksleepmust not read assleep,-g assertions); aPreventSystemSleepassertion counts only on AC; the verdict and its advice for battery, AC, keep-awake requested but not held, and no signal. - Service: 6 tests. A timer firing 14 minutes late
is recorded as a sleep and reported once awake; an ordinary tick and a 20 s
stall are not; the keep-awake opt-in is read fresh, so
awake onneeds no restart;/healthcarriespowerand omits it when no monitor is wired. - Console and launcher: 121 tests across the touched
files.
doctornames a Mac on battery with sleep allowed,clankie awake onand the hosted alternative; it stays silent with nopmset; the service'slastSleeparrives through the one existing/healthprobe.awake onspawns exactlycaffeinate -s, stores the opt-in, and only ever askspmsetwith-g;offstops the process it started; acaffeinate -sthe owner started is neither conflicted with nor mistaken for the launcher's.
What the fakes cannot show
- That a real Mac wakes and every part recovers together.
- That
caffeinate -skeeps a lid-closed MacBook awake on AC. Thecaffeinatemanual documents-sas an AC-only system-sleep assertion; clamshell behavior is macOS's own and untested here. - The app-side display. This repo ships the signal (
poweron/health, the@clankie/protocol/host-powercontract); rendering it in the app is inclankie-app, not done here. lastSleepafter a service restart: it is in memory.
The wake test (for James)
Before you start: Amphetamine and a caffeinate were holding this Mac awake when
this was written (pmset -g assertions). Quit them, or every step below reads
"awake" for the wrong reason. Have the app paired and a second device that can
send to Clankie in Discord.
A. The default: sleep, then recover
- Confirm the baseline:
clankie doctor | jq .power. On battery you should see"state": "sleep_allowed"withadvice. Noteclankie statusisready. - Keep-awake is on by default (VUH-2393): run
clankie awake off, then make sureclankie awake statussays"keepAwake": false. Runclankie awake onafter this test if you want the default back. - Note the time, then
pmset sleepnow(or close the lid on battery). - From the second device, wait two minutes, then send a Discord message that addresses Clankie (a mention or DM). Also send one more a minute later.
- Leave the Mac asleep at least 10 minutes. For the sign-in check, one run of an hour or more, so the account access token has expired at wake (I did not check its configured lifetime).
- Wake it (key press or open the lid). Do nothing else. Within about a minute:
clankie statusreturnsready,clankie gateway statusshows the doorwayconnectedwith no sign-in prompt (VUH-1451).- Clankie replies to both messages sent while it slept (VUH-1447).
- The app opens and loads its conversation without re-pairing.
curl -s 127.0.0.1:4310/health | jq .power.lastSleepshowssleptAt,wokeAtandsecondsclose to the time it slept, andclankie doctor | jq .power.lastSleepmatches.- The service log has a
host.sleptevent.
- Failure to record: which of the three did not recover, and the
clankie gateway statusand doorway log lines at wake.
B. The awake Mac
- Plug in. With no stored choice keep-awake is already on; otherwise
clankie awake on. Expect"keepAwake": true,service.statehealthy, andpmset -g assertions | grep -B1 -A1 caffeinateshowingPreventSystemSleepfor acaffeinateyou did not start by hand. clankie doctor | jq .power:statealways_on,heldAwakeByincludescaffeinate, no advice.clankie statuslistsawakeas healthy.- Lid open, idle past your battery sleep time is not informative if AC sleep is already "never". The informative checks are the next two.
- Lid closed on AC (no external display) for 5 minutes. Send a Discord message from the second device. Record whether the Mac stayed awake and Clankie answered. This is the claim the fakes cannot make; either result is useful.
- Unplug.
clankie doctor | jq .powershould now saysleep_allowed,sourcebattery, and the advice should mention that keep-awake only holds while plugged in. Leave it idle: the Mac should sleep on your battery timer even thoughcaffeinateis still running. clankie awake off.pgrep -x caffeinateshows no launcher-started process, andpmset -g customis unchanged from before step 1.- Reboot with
clankie autostart enableset andawake on: after login,clankie awake statusis healthy without running anything by hand.
Attach the outputs of the commands above, and the failure record if any step failed, to VUH-1461.
