the server-side deploy script ignored which commit CI tested and deployed whatever main was;
it used npm install --production;
its only health check was systemctl is-active, and there was no rollback;
the deploy webhook could be replayed, because its signed payload never changed.
What changes
GET /healthz (unauthenticated) returns the running git sha, the version, db reachability, connected workers and uptime_s. It returns 503 when the database is down.
deploy/pulse_deploy.sh is versioned for the first time; it only existed as a hand-edited file on CT 122. It takes <sha> <ts> from the signed payload and:
refuses requests older than 5 minutes, or not newer than the last accepted one (replays);
refuses commits that aren't on main;
checks out exactly that sha, runs npm ci --omit=dev and restarts;
waits for /healthz to report that sha with a working database, and otherwise rolls back to the previous commit.
Tests:tests/deploy-script.test.js runs the real script in a sandbox (a temporary git origin, with fake systemctl, npm and curl). It covers:
deploying an exact sha while keeping .env;
a replay;
a stale request;
an off-main commit;
malformed input;
rolling back an unhealthy build.
These run in CI on every push.
CI deploy step: it now succeeds only once production reports the tested sha as healthy, and tags only after that.
README: a new CI/CD and Deploys section, including how to install the script and the hooks.json arguments.
Rollout
Merge. The old server script deploys this commit, because it is the tip of main. CI then sees /healthz report it, so this deploy already exercises the new verification.
Install the new script on CT 122 (install -m 755 deploy/pulse_deploy.sh /usr/local/bin/), and add pass-arguments-to-command (sha, ts) to the pulse-deploy hook, keeping a backup of both.
The next merge runs through the new script end to end.
Verified
jest: 67 tests pass (6 new deploy-script scenarios). /healthz returns 200 with the database up and 503 with it down, checked against the stubbed server.
Phase 2 of #45.
## Why
Until now:
- the server-side deploy script ignored which commit CI tested and deployed whatever `main` was;
- it used `npm install --production`;
- its only health check was `systemctl is-active`, and there was no rollback;
- the deploy webhook could be replayed, because its signed payload never changed.
## What changes
- **`GET /healthz`** (unauthenticated) returns the running git `sha`, the version, `db` reachability, connected `workers` and `uptime_s`. It returns 503 when the database is down.
- **`deploy/pulse_deploy.sh`** is versioned for the first time; it only existed as a hand-edited file on CT 122. It takes `<sha> <ts>` from the signed payload and:
- refuses requests older than 5 minutes, or not newer than the last accepted one (replays);
- refuses commits that aren't on `main`;
- checks out **exactly** that sha, runs `npm ci --omit=dev` and restarts;
- waits for `/healthz` to report that sha with a working database, and otherwise **rolls back** to the previous commit.
- **Tests:** `tests/deploy-script.test.js` runs the real script in a sandbox (a temporary git origin, with fake `systemctl`, `npm` and `curl`). It covers:
- deploying an exact sha while keeping `.env`;
- a replay;
- a stale request;
- an off-main commit;
- malformed input;
- rolling back an unhealthy build.
These run in CI on every push.
- **CI deploy step:** it now succeeds only once production reports the tested sha as healthy, and tags only after that.
- **README:** a new CI/CD and Deploys section, including how to install the script and the `hooks.json` arguments.
## Rollout
1. Merge. The **old** server script deploys this commit, because it is the tip of `main`. CI then sees `/healthz` report it, so this deploy already exercises the new verification.
2. Install the new script on CT 122 (`install -m 755 deploy/pulse_deploy.sh /usr/local/bin/`), and add `pass-arguments-to-command` (sha, ts) to the `pulse-deploy` hook, keeping a backup of both.
3. The next merge runs through the new script end to end.
## Verified
- jest: 67 tests pass (6 new deploy-script scenarios). `/healthz` returns 200 with the database up and 503 with it down, checked against the stubbed server.
- Branch CI is green on the real runner.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
#45 phase 2.
- GET /healthz (unauthenticated): running git sha, version, database
reachability, connected workers, uptime. 503 when the database is down.
- deploy/pulse_deploy.sh, versioned for the first time (it only existed
as a hand-edited file on CT 122). It takes <sha> <ts> from the signed
webhook payload and:
- refuses requests older than 5 minutes, or not newer than the last
accepted one (replays);
- refuses commits that aren't on main;
- checks out exactly that sha (before, it deployed whatever main was);
- runs npm ci --omit=dev (before, npm install --production) and
restarts;
- waits for /healthz to report the sha with a working database, and
otherwise rolls back to the previous commit.
- tests/deploy-script.test.js runs the script in a sandbox (temporary git
origin, fake systemctl/npm/curl): exact-sha deploy with .env kept, replay,
stale request, off-main commit, malformed input, and rollback of an
unhealthy build.
- CI's deploy job now succeeds only once production reports the tested sha
as healthy, before tagging. Before, it only checked that the server
answered.
- README: CI/CD and deploy documentation, including installing the script
and the hooks.json arguments.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared
scheduled this pull request to auto merge when all checks succeed 2026-11-22 02:27:11 -05:00
jared
merged commit be6eaad1e9 into main2026-11-22 02:27:12 -05:00
jared
deleted branch ci-phase22026-11-22 02:27:18 -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.
Phase 2 of #45.
Why
Until now:
mainwas;npm install --production;systemctl is-active, and there was no rollback;What changes
GET /healthz(unauthenticated) returns the running gitsha, the version,dbreachability, connectedworkersanduptime_s. It returns 503 when the database is down.deploy/pulse_deploy.shis versioned for the first time; it only existed as a hand-edited file on CT 122. It takes<sha> <ts>from the signed payload and:main;npm ci --omit=devand restarts;/healthzto report that sha with a working database, and otherwise rolls back to the previous commit.Tests:
tests/deploy-script.test.jsruns the real script in a sandbox (a temporary git origin, with fakesystemctl,npmandcurl). It covers:.env;These run in CI on every push.
CI deploy step: it now succeeds only once production reports the tested sha as healthy, and tags only after that.
README: a new CI/CD and Deploys section, including how to install the script and the
hooks.jsonarguments.Rollout
main. CI then sees/healthzreport it, so this deploy already exercises the new verification.install -m 755 deploy/pulse_deploy.sh /usr/local/bin/), and addpass-arguments-to-command(sha, ts) to thepulse-deployhook, keeping a backup of both.Verified
/healthzreturns 200 with the database up and 503 with it down, checked against the stubbed server.🤖 Generated with Claude Code