Closes#40 (except showing the version in the Workers tab, which is a UI change and will get its own screenshot PR).
Version reporting
The worker reports the commit it runs: the VERSION file written by the deploy, or git rev-parse when it runs from a checkout. It sends this in worker_connect and in heartbeat metadata.
The server accepts only a 40-character sha (anything else becomes unknown), stores it on the live socket, and lists worker_versions in /healthz. These are commit SHAs of a public repo, alongside the server's own sha, which /healthz already shows.
deploy/pulse_worker_deploy.sh <sha> <ts>
This is for the webhook on a worker host (CT 153). It follows the same pattern as pulse_deploy.sh:
Refuses replayed or stale requests, and commits that aren't on main.
Reads worker/worker.js, package.json and package-lock.json at exactly that commit from a local clone of the public repo, installs them, writes VERSION, runs npm ci --omit=dev and restarts. It never touches .env.
Waits until /healthz lists the sha; otherwise it restores the previous files.
tests/worker-deploy-script.test.js adds 6 sandbox tests: replacing the hand-installed worker, replay, stale and malformed input, an off-main commit, a no-op redeploy, and rollback.
CI: Deploy worker (after Deploy)
Deploys only when worker/ or the npm manifests changed since the commit the workers report. Unrelated merges therefore don't restart the worker and interrupt Gandalf's commands.
Signs {ref, sha, ts} with the WORKER_WEBHOOK_SECRET secret, calls http://10.10.10.151:9000/hooks/pulse-worker-deploy, then waits up to 4 minutes for the worker to reconnect on the new commit.
This isn't a required check, since it only runs on main.
Before merging (CT 153 setup)
Install the script at /usr/local/bin/pulse_worker_deploy.sh.
Add the pulse-worker-deploy hook to /etc/webhook/hooks.json, with a new secret. The pve-infra deploy only manages the unit file, so the hook persists.
Store the same secret as the repo's WORKER_WEBHOOK_SECRET.
The first run will replace the hand-installed package.json with the repo's. The worker will then also install the server's dependencies, which is harmless.
Locally: jest 83/83, integration 21/21, Playwright 30/30, and lint, shellcheck and actionlint are clean.
Closes #40 (except showing the version in the Workers tab, which is a UI change and will get its own screenshot PR).
## Version reporting
- The worker reports the commit it runs: the `VERSION` file written by the deploy, or `git rev-parse` when it runs from a checkout. It sends this in `worker_connect` and in heartbeat metadata.
- The server accepts only a 40-character sha (anything else becomes `unknown`), stores it on the live socket, and lists `worker_versions` in `/healthz`. These are commit SHAs of a public repo, alongside the server's own `sha`, which `/healthz` already shows.
## `deploy/pulse_worker_deploy.sh <sha> <ts>`
This is for the webhook on a worker host (CT 153). It follows the same pattern as `pulse_deploy.sh`:
- Refuses replayed or stale requests, and commits that aren't on `main`.
- Reads `worker/worker.js`, `package.json` and `package-lock.json` at exactly that commit from a local clone of the public repo, installs them, writes `VERSION`, runs `npm ci --omit=dev` and restarts. It never touches `.env`.
- Waits until `/healthz` lists the sha; otherwise it **restores the previous files**.
- `tests/worker-deploy-script.test.js` adds 6 sandbox tests: replacing the hand-installed worker, replay, stale and malformed input, an off-main commit, a no-op redeploy, and rollback.
## CI: `Deploy worker` (after `Deploy`)
- Deploys only when `worker/` or the npm manifests changed since the commit the workers report. Unrelated merges therefore don't restart the worker and interrupt Gandalf's commands.
- Signs `{ref, sha, ts}` with the `WORKER_WEBHOOK_SECRET` secret, calls `http://10.10.10.151:9000/hooks/pulse-worker-deploy`, then waits up to 4 minutes for the worker to reconnect on the new commit.
- This isn't a required check, since it only runs on `main`.
## Before merging (CT 153 setup)
1. Install the script at `/usr/local/bin/pulse_worker_deploy.sh`.
2. Add the `pulse-worker-deploy` hook to `/etc/webhook/hooks.json`, with a new secret. The pve-infra deploy only manages the unit file, so the hook persists.
3. Store the same secret as the repo's `WORKER_WEBHOOK_SECRET`.
The first run will replace the hand-installed `package.json` with the repo's. The worker will then also install the server's dependencies, which is harmless.
Locally: jest 83/83, integration 21/21, Playwright 30/30, and lint, shellcheck and actionlint are clean.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
- 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>
jared
merged commit e167e2f3b8 into main2026-11-22 18:58:06 -05:00
jared
deleted branch worker-deploy2026-11-22 18:58:09 -05:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #40 (except showing the version in the Workers tab, which is a UI change and will get its own screenshot PR).
Version reporting
VERSIONfile written by the deploy, orgit rev-parsewhen it runs from a checkout. It sends this inworker_connectand in heartbeat metadata.unknown), stores it on the live socket, and listsworker_versionsin/healthz. These are commit SHAs of a public repo, alongside the server's ownsha, which/healthzalready shows.deploy/pulse_worker_deploy.sh <sha> <ts>This is for the webhook on a worker host (CT 153). It follows the same pattern as
pulse_deploy.sh:main.worker/worker.js,package.jsonandpackage-lock.jsonat exactly that commit from a local clone of the public repo, installs them, writesVERSION, runsnpm ci --omit=devand restarts. It never touches.env./healthzlists the sha; otherwise it restores the previous files.tests/worker-deploy-script.test.jsadds 6 sandbox tests: replacing the hand-installed worker, replay, stale and malformed input, an off-main commit, a no-op redeploy, and rollback.CI:
Deploy worker(afterDeploy)worker/or the npm manifests changed since the commit the workers report. Unrelated merges therefore don't restart the worker and interrupt Gandalf's commands.{ref, sha, ts}with theWORKER_WEBHOOK_SECRETsecret, callshttp://10.10.10.151:9000/hooks/pulse-worker-deploy, then waits up to 4 minutes for the worker to reconnect on the new commit.main.Before merging (CT 153 setup)
/usr/local/bin/pulse_worker_deploy.sh.pulse-worker-deployhook to/etc/webhook/hooks.json, with a new secret. The pve-infra deploy only manages the unit file, so the hook persists.WORKER_WEBHOOK_SECRET.The first run will replace the hand-installed
package.jsonwith the repo's. The worker will then also install the server's dependencies, which is harmless.Locally: jest 83/83, integration 21/21, Playwright 30/30, and lint, shellcheck and actionlint are clean.
🤖 Generated with Claude Code