- #1: the worker pings the server every 30 s over the WebSocket; if the
previous ping got no pong, the connection is dead (server restart or
network drop without a close) and is terminated so it reconnects. The
ws server answers pings itself, so the server needs no change.
- #29: reconnects back off from 1 s doubling to 60 s with up to 20%
jitter, reset on a successful connection; a failed first heartbeat is
logged and retried instead of exiting into a systemd crash loop.
- stop() no longer schedules a reconnect.
- Tests: backoff bounds, missed pong terminates, pong keeps, startup with
an unreachable server (unit and end to end). The #6 test now waits for
the worker to show offline before sending one command.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- #6: a quick command to a disconnected worker is refused before an
execution is recorded, instead of leaving one stuck in 'running'.
- #21: an unanswered prompt fails the execution (prompt_timeout) instead
of continuing as if someone had chosen; prompt and wait steps never
wait past the execution's deadline, and a wait cut short by it fails
with execution_timeout. PULSE_PROMPT_TIMEOUT_MS (minimum 1 s, default
60 min) lets the test stack use 8 s.
- #34: deleting a connected worker is a 409 explaining it would
re-register on its next heartbeat; offline workers delete as before.
Tests for each (integration 45/45).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- worker: commands run with spawn in their own process group (same
timeout, 10 MB output limit and result fields as exec). A new
cancel_command message (by command_id, or every command of an
execution) sends SIGTERM to the group, then SIGKILL after 5 s; the
result reports cancelled: true. Old workers ignore the message.
- server: the abort route sends cancel_command to the worker running each
of the execution's commands.
- Tests: the whole process tree dies on cancel (a background child too),
execution-wide cancel leaves other executions alone, and end to end an
aborted quick command's process is gone from the worker. Liveness
checks treat zombies as dead (an orphan waits to be reaped).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The worker reports its commit (VERSION file, or git rev-parse in a
checkout) in worker_connect and heartbeat metadata. The server keeps it
per live socket and /healthz lists worker_versions.
- deploy/pulse_worker_deploy.sh <sha> <ts>, for the webhook on a worker
host: replay and age checks, commit must be on main, installs worker.js
and the npm manifests from exactly that commit, writes VERSION, npm ci,
restarts, waits until /healthz lists the sha, else restores the
previous files. Sandbox tests cover deploy, replay, stale and malformed
input, off-main commits, no-op redeploys and rollback.
- New CI job Deploy worker after Deploy: only when worker/ or the npm
manifests changed since the commit the workers report, so unrelated
merges don't restart the worker; then waits for the worker to reconnect
on the new commit.
- README: Worker deploys (install, hook definition, adding a worker host).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New CI job `Integration (api)` (#45 phase 3) runs the real server and three
workers on Node 20 against MariaDB and tests them as a black box over HTTP
and WebSocket (20 tests, about 12 s):
- Gandalf contract: submit and poll, stdout from command_result, failures
with exit code and stderr, 401 for wrong or missing key, 400 for missing
fields or an unknown worker, 404 for an unknown execution
- Auth: SSO identity, 401/403, heartbeat key, /healthz exposes only status;
WebSocket upgrade refused without credentials, with a wrong key or a wrong
group; live events reach a signed-in browser; a browser socket cannot
forge a command result
- Reliability: a worker killed mid-command fails the execution at once; a
worker at capacity answers with a failure; an aborted execution stays
failed when the late result arrives; a disconnected worker shows offline
The last test found a bug from #42: the close handler deleted the worker's
runtime-id entry before checking whether the socket was still live under its
database id, and the two ids are normally the same key. So a disconnected
worker was never marked offline and showed 'online' until the stale
heartbeat sweep. Gandalf was unaffected (it checks live sockets).
MariaDB setup for CI moves to scripts/ci/mariadb.sh, shared by both jobs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>