Tracking issue for a full rework of Pulse's CI/CD pipeline. The goals: nothing reaches production unless it is tested; tests catch real regressions in server.js and the worker; security problems are caught in CI rather than in production; and a deploy can be verified and rolled back.
Current state (audited 2026-11-22)
Pipeline
Workflow
What it does
Problems
lint.yml
eslint, Matrix alert on failure, deploy on push to main, tag
Deploy needs: [js-lint] only. Tests and npm audit run in separate workflows, so a merge that fails tests still deploys. It installs eslint with npm install --save-dev eslint@8, which ignores the lockfile and modifies package.json mid-run. The Matrix alert only fires when lint fails.
test.yml
npm install then jest --coverage
npm install, not npm ci. There is no coverage threshold. Coverage covers lib/ only: server.js (about 2,000 lines, all routes, the WebSocket handling, the workflow engine and the scheduler) has no tests.
security.yml
npm audit --audit-level=high, weekly cron
It's the only security check. There's no secret scanning, no SAST, no dependency or licence review, and no workflow linting.
Across all three:
Actions are pinned by tag (actions/checkout@v3), not by commit SHA.
The Node version is whatever the runner has.
There's no workflow-level permissions: block. The deploy job asks for contents: write.
There's no concurrency: control, so two quick merges can deploy at the same time.
Branch protection requires lint only.
Deploy (/usr/local/bin/pulse_deploy.sh on CT 122, triggered by the webhook)
It ignores the ref in the payload and runs git reset --hard origin/main. It deploys whatever main is when it runs, not the commit CI tested.
It uses npm install --production. That isn't reproducible, can rewrite the lockfile, and --production is deprecated in favour of --omit=dev.
The only health check is systemctl is-active after 2 s. There's no HTTP or WebSocket check and no rollback: a bad build stays down until someone fixes it.
It backs up .env to a fixed path in /tmp.
Webhook replay: the signed payload is always {"ref":"refs/heads/main"}, so the HMAC signature never changes. Anyone who sees one request on the LAN (plain HTTP to :9000) can replay it to restart Pulse at will. The listener runs as root.
Phase 1: Gate deploys and make builds reproducible (urgent, small)
Combine into one ci.yml with jobs lint, test, audit and deploy, where deploy needs: [lint, test, audit] and runs only on push to main. Alternatively, keep separate files and gate deploy with workflow_run.
Use npm ci everywhere, use the lockfile's eslint, and add an npm run lint script.
Add actions/setup-node pinned to the production Node major version (20), with an npm cache.
Set permissions: contents: read at the top and grant more per job only where needed. Add concurrency: deploy-production with cancel-in-progress: false.
Pin every action to a full commit SHA, with a comment giving the version.
Send the Matrix alert when any job fails on main, and when a deploy succeeds or fails.
Branch protection: require lint, test and audit.
Phase 2: Deploy safety
CI sends the tested SHA. pulse_deploy.sh checks out exactly that SHA (git fetch + git checkout --detach <sha>) and refuses anything that isn't on origin/main.
Replay protection: sign {sha, timestamp, nonce}, reject timestamps more than 5 minutes old, and remember recent nonces. Move the webhook behind TLS or restrict it to the runner's address.
Use npm ci --omit=dev. Back up .env with mktemp and mode 600.
Add a real health check: a new GET /healthz that returns the version, the git SHA, DB connectivity and the number of connected workers. The deploy polls it for 30 s, and CI checks it remotely too.
Automatic rollback: keep the previous SHA. If the health check fails, check it out again, run npm ci, restart, and alert.
Create the deploy-* tag only after the health check passes.
Run the webhook listener as a less privileged user, with sudo rights limited to systemctl restart pulse.
Phase 3: Real tests
Refactor server.js into an app factory (createApp({ pool, env })), so tests can start it on a random port without starting the background timers.
Integration tests against a real MariaDB (CI service container), using supertest and ws. Add the existing ad-hoc harnesses from #41/#42 as proper tests:
auth: trusted proxy and spoofed headers (#37); WebSocket classification and enforcement (#38);
command results bound to the right worker, replays dropped (#38);
timeouts, disconnects, the terminal-state guard and the reconnect race (#7);
Gandalf's contract: POST /api/internal/command, then polling /api/internal/executions/:id gives completed and stdout, or failed.
The workflow engine: goto, conditions, prompts and abort (#8, #20).
The scheduler.
Worker unit tests: capacity rejection, failure fields, the handshake key.
Coverage thresholds that only go up (start near current levels and raise them as tests land). Publish the coverage report as an artifact.
Run the tests against both Node 20 and 22.
Phase 4: Security scanning
Secret scanning with gitleaks on every push, over full history once.
SAST with semgrep (Node/Express rulesets, plus custom rules: no exec with user input, no vm misuse, no unescaped innerHTML).
Dependency review on PRs: fail when a new dependency has a known vulnerability or a disallowed licence. Run npm audit signatures.
Lint the workflow files with actionlint and zizmor (catches injection through ${{ github.* }} in run:).
Renovate (or a scheduled job) to update dependencies and action SHAs, with PRs merged automatically once CI passes.
Generate an SBOM (CycloneDX) on each deploy and attach it to the tag.
Phase 5: Accuracy and UI review automation
No em or en dashes check: fail when U+2013/U+2014, —/– or their escapes appear in Pulse-owned files (house style).
Stricter eslint: turn current warnings into errors once fixed, add eslint-plugin-security, and lint the browser JS (public/assets) with browser globals.
Check that public/web_template/ matches the VERSION it claims (no hand edits).
Screenshots on UI PRs: when a PR touches views/, public/assets/ or lib/render.js, CI starts the demo instance (scripts/demo/: MariaDB, server, 3 workers, seed), captures main and the PR with Playwright, posts a before/after image as a PR comment, and labels the PR needs-visual-approval. This automates the current rule that UI changes need screenshot approval.
A Playwright smoke test (every page loads, live WebSocket connects, quick command round trip) as a required check.
Deploy worker/worker.js to CT 153 through the existing pve-infra webhook, or a Pulse-side hook, at the same tested SHA.
The worker reports its version, and /healthz and the Workers tab show drift.
Suggested order
Phase 1 first: it's small, and it closes the "untested code reaches production" gap. Then Phase 2 (safe deploys), then Phase 3 (tests), which is the biggest gain in correctness. Phases 4 to 6 can run in parallel after that. Each phase lands as its own PR or PRs.
Tracking issue for a full rework of Pulse's CI/CD pipeline. The goals: nothing reaches production unless it is tested; tests catch real regressions in `server.js` and the worker; security problems are caught in CI rather than in production; and a deploy can be verified and rolled back.
## Current state (audited 2026-11-22)
### Pipeline
| Workflow | What it does | Problems |
|---|---|---|
| `lint.yml` | eslint, Matrix alert on failure, **deploy on push to main**, tag | Deploy `needs: [js-lint]` only. **Tests and npm audit run in separate workflows, so a merge that fails tests still deploys.** It installs eslint with `npm install --save-dev eslint@8`, which ignores the lockfile and modifies `package.json` mid-run. The Matrix alert only fires when lint fails. |
| `test.yml` | `npm install` then `jest --coverage` | `npm install`, not `npm ci`. There is no coverage threshold. Coverage covers `lib/` only: `server.js` (about 2,000 lines, all routes, the WebSocket handling, the workflow engine and the scheduler) has **no tests**. |
| `security.yml` | `npm audit --audit-level=high`, weekly cron | It's the only security check. There's no secret scanning, no SAST, no dependency or licence review, and no workflow linting. |
Across all three:
- Actions are pinned by tag (`actions/checkout@v3`), not by commit SHA.
- The Node version is whatever the runner has.
- There's no workflow-level `permissions:` block. The deploy job asks for `contents: write`.
- There's no `concurrency:` control, so two quick merges can deploy at the same time.
- Branch protection requires `lint` only.
### Deploy (`/usr/local/bin/pulse_deploy.sh` on CT 122, triggered by the webhook)
- **It ignores the ref in the payload** and runs `git reset --hard origin/main`. It deploys whatever `main` is when it runs, not the commit CI tested.
- It uses `npm install --production`. That isn't reproducible, can rewrite the lockfile, and `--production` is deprecated in favour of `--omit=dev`.
- The only health check is `systemctl is-active` after 2 s. There's no HTTP or WebSocket check and **no rollback**: a bad build stays down until someone fixes it.
- It backs up `.env` to a fixed path in `/tmp`.
- **Webhook replay:** the signed payload is always `{"ref":"refs/heads/main"}`, so the HMAC signature never changes. Anyone who sees one request on the LAN (plain HTTP to `:9000`) can replay it to restart Pulse at will. The listener runs as root.
- **Workers aren't deployed at all** (#40).
## Plan
### Phase 1: Gate deploys and make builds reproducible (urgent, small)
- [ ] Combine into one `ci.yml` with jobs `lint`, `test`, `audit` and `deploy`, where deploy `needs: [lint, test, audit]` and runs only on push to `main`. Alternatively, keep separate files and gate deploy with `workflow_run`.
- [ ] Use `npm ci` everywhere, use the lockfile's eslint, and add an `npm run lint` script.
- [ ] Add `actions/setup-node` pinned to the production Node major version (20), with an npm cache.
- [ ] Set `permissions: contents: read` at the top and grant more per job only where needed. Add `concurrency: deploy-production` with `cancel-in-progress: false`.
- [ ] Pin every action to a full commit SHA, with a comment giving the version.
- [ ] Send the Matrix alert when any job fails on `main`, and when a deploy succeeds or fails.
- [ ] Branch protection: require `lint`, `test` and `audit`.
### Phase 2: Deploy safety
- [ ] CI sends the **tested SHA**. `pulse_deploy.sh` checks out exactly that SHA (`git fetch` + `git checkout --detach <sha>`) and refuses anything that isn't on `origin/main`.
- [ ] Replay protection: sign `{sha, timestamp, nonce}`, reject timestamps more than 5 minutes old, and remember recent nonces. Move the webhook behind TLS or restrict it to the runner's address.
- [ ] Use `npm ci --omit=dev`. Back up `.env` with `mktemp` and mode 600.
- [ ] Add a real health check: a new `GET /healthz` that returns the version, the git SHA, DB connectivity and the number of connected workers. The deploy polls it for 30 s, and CI checks it remotely too.
- [ ] **Automatic rollback:** keep the previous SHA. If the health check fails, check it out again, run `npm ci`, restart, and alert.
- [ ] Create the `deploy-*` tag only after the health check passes.
- [ ] Run the webhook listener as a less privileged user, with sudo rights limited to `systemctl restart pulse`.
### Phase 3: Real tests
- [ ] Refactor `server.js` into an app factory (`createApp({ pool, env })`), so tests can start it on a random port without starting the background timers.
- [ ] **Integration tests against a real MariaDB** (CI service container), using `supertest` and `ws`. Add the existing ad-hoc harnesses from #41/#42 as proper tests:
- auth: trusted proxy and spoofed headers (#37); WebSocket classification and enforcement (#38);
- command results bound to the right worker, replays dropped (#38);
- timeouts, disconnects, the terminal-state guard and the reconnect race (#7);
- error details (#14);
- **Gandalf's contract**: `POST /api/internal/command`, then polling `/api/internal/executions/:id` gives `completed` and stdout, or `failed`.
- The workflow engine: goto, conditions, prompts and abort (#8, #20).
- The scheduler.
- [ ] Worker unit tests: capacity rejection, failure fields, the handshake key.
- [ ] Coverage thresholds that only go up (start near current levels and raise them as tests land). Publish the coverage report as an artifact.
- [ ] Run the tests against both Node 20 and 22.
### Phase 4: Security scanning
- [ ] Secret scanning with **gitleaks** on every push, over full history once.
- [ ] SAST with **semgrep** (Node/Express rulesets, plus custom rules: no `exec` with user input, no `vm` misuse, no unescaped `innerHTML`).
- [ ] **Dependency review** on PRs: fail when a new dependency has a known vulnerability or a disallowed licence. Run `npm audit signatures`.
- [ ] Lint the workflow files with **actionlint** and **zizmor** (catches injection through `${{ github.* }}` in `run:`).
- [ ] Renovate (or a scheduled job) to update dependencies and action SHAs, with PRs merged automatically once CI passes.
- [ ] Generate an SBOM (CycloneDX) on each deploy and attach it to the tag.
### Phase 5: Accuracy and UI review automation
- [ ] **No em or en dashes** check: fail when U+2013/U+2014, `—`/`–` or their escapes appear in Pulse-owned files (house style).
- [ ] Stricter eslint: turn current warnings into errors once fixed, add `eslint-plugin-security`, and lint the browser JS (`public/assets`) with browser globals.
- [ ] Check that `public/web_template/` matches the `VERSION` it claims (no hand edits).
- [ ] **Screenshots on UI PRs:** when a PR touches `views/`, `public/assets/` or `lib/render.js`, CI starts the demo instance (`scripts/demo/`: MariaDB, server, 3 workers, seed), captures main and the PR with Playwright, posts a before/after image as a PR comment, and labels the PR `needs-visual-approval`. This automates the current rule that UI changes need screenshot approval.
- [ ] A Playwright smoke test (every page loads, live WebSocket connects, quick command round trip) as a required check.
### Phase 6: Workers in the pipeline (with #40)
- [ ] Deploy `worker/worker.js` to CT 153 through the existing pve-infra webhook, or a Pulse-side hook, at the same tested SHA.
- [ ] The worker reports its version, and `/healthz` and the Workers tab show drift.
## Suggested order
Phase 1 first: it's small, and it closes the "untested code reaches production" gap. Then Phase 2 (safe deploys), then Phase 3 (tests), which is the biggest gain in correctness. Phases 4 to 6 can run in parallel after that. Each phase lands as its own PR or PRs.
Related: #40 (worker deployment), #28 (docs).
GET /healthz reports the running sha, the database and connected workers.
deploy/pulse_deploy.sh is versioned and installed on CT 122 (old copy kept as .bak-2026-11-22). It deploys exactly the signed sha, rejects stale or replayed requests and off-main commits, uses npm ci --omit=dev, waits for /healthz, and rolls back automatically.
Its behaviour is covered by sandbox tests in CI.
CI tags a deploy only once production reports the tested sha.
Still open from phase 2: run the webhook listener as a less privileged user.
First gate catch: on #48's merge, setup-node failed transiently with no error, and deploy was correctly skipped. The rerun is in progress. If this recurs, drop cache: npm or add a retry.
Addition to Phase 5: frontend and UI/UX testing in the same pipeline (requested)
Playwright is already available, so:
Add a ui job to ci.yml that runs alongside test:
start a throwaway MariaDB as a service container;
start the Pulse server and 3 demo workers;
seed with scripts/demo/seed.py.
Have it run Playwright tests (tests/ui/*.spec.js):
every page renders with no console errors;
the live WebSocket connects and updates;
quick command round trip; workflow create, run and prompt response; scheduler create;
Make ui a required check, so it gates deploy like lint, test and audit.
On PRs that touch the UI, post the automatic before/after screenshots (above) to the PR.
From now on, UI bug fixes and improvements come with a Playwright test that reproduces the bug first.
## Progress (2026-11-22)
**Phase 1: done** (#46)
- One `ci.yml`; deploy waits for lint, test and audit.
- `npm ci` everywhere, Node 20, actions pinned to commit SHAs.
- Read-only permissions by default; deploys can't overlap.
- Matrix alerts on any failure and on every deploy.
- A no-dash check.
- The new audit gate caught `proxy-addr` (critical) and `body-parser`/`follow-redirects` (high), now fixed.
- Branch protection now requires the three CI checks.
**Phase 2: done** (#47)
- `GET /healthz` reports the running sha, the database and connected workers.
- `deploy/pulse_deploy.sh` is versioned and installed on CT 122 (old copy kept as `.bak-2026-11-22`). It deploys exactly the signed sha, rejects stale or replayed requests and off-main commits, uses `npm ci --omit=dev`, waits for `/healthz`, and rolls back automatically.
- Its behaviour is covered by sandbox tests in CI.
- CI tags a deploy only once production reports the tested sha.
- Still open from phase 2: run the webhook listener as a less privileged user.
**First gate catch:** on #48's merge, `setup-node` failed transiently with no error, and **deploy was correctly skipped**. The rerun is in progress. If this recurs, drop `cache: npm` or add a retry.
## Addition to Phase 5: frontend and UI/UX testing in the same pipeline (requested)
Playwright is already available, so:
- [ ] Add a `ui` job to `ci.yml` that runs alongside `test`:
- start a throwaway MariaDB as a service container;
- start the Pulse server and 3 demo workers;
- seed with `scripts/demo/seed.py`.
- [ ] Have it run Playwright tests (`tests/ui/*.spec.js`):
- every page renders with no console errors;
- the live WebSocket connects and updates;
- quick command round trip; workflow create, run and prompt response; scheduler create;
- the error pages;
- keyboard shortcuts;
- a narrow-viewport layout check (#24).
- [ ] Make `ui` a required check, so it gates deploy like `lint`, `test` and `audit`.
- [ ] On PRs that touch the UI, post the automatic before/after screenshots (above) to the PR.
- [ ] From now on, UI bug fixes and improvements come with a Playwright test that reproduces the bug first.
Phase 5: the Playwright UI job is live (#49), and deploys now wait for it.
UI (playwright) job: runs the real server and 3 real workers (worker auth enforced) against MariaDB, then 30 tests on desktop and a Pixel 7 viewport. Coverage: pages, Quick Command end to end, workflow create and run, live WebSocket updates, the 401/403 auth paths, and mobile overflow. A shared fixture fails any test on a page error, console error or failed request. Takes about 1.5 minutes.
Deploy: first deploy through the new job was 1d5b8cd, tag on main run 142. /healthz was healthy and the worker reconnected.
Runner findings (affect every repo):
Jobs run on Docker's default bridge network, so services: containers can't be reached by name. MariaDB is now installed inside the job container instead.
All jobs share one act-toolcache volume, so concurrent actions/setup-node runs corrupt each other. That caused both of today's "setup-node" failures. Jobs now take Node from a pinned image (node:20-bookworm), and the UI job uses the Playwright image (Node 26).
Still to do in phase 5:
Make CI / UI (playwright) (push) a required check (user, branch protection)
Stricter eslint and the web_template integrity check
**Phase 5: the Playwright UI job is live (#49), and deploys now wait for it.**
- **`UI (playwright)` job:** runs the real server and 3 real workers (worker auth enforced) against MariaDB, then 30 tests on desktop and a Pixel 7 viewport. Coverage: pages, Quick Command end to end, workflow create and run, live WebSocket updates, the 401/403 auth paths, and mobile overflow. A shared fixture fails any test on a page error, console error or failed request. Takes about 1.5 minutes.
- **Deploy:** first deploy through the new job was `1d5b8cd`, tag on main run 142. `/healthz` was healthy and the worker reconnected.
**Runner findings (affect every repo):**
- Jobs run on Docker's default `bridge` network, so `services:` containers can't be reached by name. MariaDB is now installed inside the job container instead.
- All jobs share one `act-toolcache` volume, so concurrent `actions/setup-node` runs corrupt each other. That caused both of today's "setup-node" failures. Jobs now take Node from a pinned image (`node:20-bookworm`), and the UI job uses the Playwright image (Node 26).
**Still to do in phase 5:**
- [ ] Make `CI / UI (playwright) (push)` a required check (user, branch protection)
- [ ] Stricter eslint and the web_template integrity check
- [ ] Automatic before/after screenshots on UI PRs
- [ ] A Playwright test with every UI fix (#10 to #33)
Phase 3: the integration job is live (#50), deployed as 4f32bd1.
Integration (api) runs the real server and 3 workers on Node 20 against MariaDB. 20 black-box tests cover the Gandalf contract, HTTP and WebSocket auth (including forged results), and reliability (crash, capacity, abort, offline status). About 12 s.
Bug found: since #42, a disconnected worker was never marked offline. It's fixed in the same PR.
Required checks on main are now: Lint, Test, Security, Integration, UI.
Still open from phase 3:
Worker unit tests (worker/worker.js spawn, timeout and capacity logic, without a server)
Coverage thresholds
Node 22 in the matrix, only once production moves off 20
I swapped the planned app-factory refactor for black-box tests, which cover the same contracts without touching server.js. A refactor can come later if unit-level server tests ever need it.
**Phase 3: the integration job is live (#50), deployed as `4f32bd1`.**
`Integration (api)` runs the real server and 3 workers on Node 20 against MariaDB. 20 black-box tests cover the Gandalf contract, HTTP and WebSocket auth (including forged results), and reliability (crash, capacity, abort, offline status). About 12 s.
**Bug found:** since #42, a disconnected worker was never marked offline. It's fixed in the same PR.
**Required checks on `main` are now:** Lint, Test, Security, Integration, UI.
**Still open from phase 3:**
- [ ] Worker unit tests (`worker/worker.js` spawn, timeout and capacity logic, without a server)
- [ ] Coverage thresholds
- [ ] Node 22 in the matrix, only once production moves off 20
I swapped the planned app-factory refactor for black-box tests, which cover the same contracts without touching `server.js`. A refactor can come later if unit-level server tests ever need it.
Phase 4: the scan job is live (#51), deployed as 15f8ec4.
Scan (secrets, workflows, shell) runs on every push and PR, and it's now a required check:
gitleaks over the full history, with redacted output: no leaks in 88 commits;
actionlint on the workflow files, which includes shellcheck on their run: scripts;
shellcheck on every *.sh.
The tool downloads are pinned and checked against SHA-256 sums.
Still open in phase 4:
semgrep (needs a Python install in the job, or its container image)
Renovate for dependency and action-pin updates (needs a Gitea bot account and token: user decision)
SBOM on deploy (CycloneDX via npm sbom)
**Phase 4: the scan job is live (#51), deployed as `15f8ec4`.**
`Scan (secrets, workflows, shell)` runs on every push and PR, and it's now a required check:
- gitleaks over the full history, with redacted output: no leaks in 88 commits;
- actionlint on the workflow files, which includes shellcheck on their `run:` scripts;
- shellcheck on every `*.sh`.
The tool downloads are pinned and checked against SHA-256 sums.
**Still open in phase 4:**
- [ ] semgrep (needs a Python install in the job, or its container image)
- [ ] Renovate for dependency and action-pin updates (needs a Gitea bot account and token: user decision)
- [ ] SBOM on deploy (CycloneDX via `npm sbom`)
coverage floors (lib/ 90% of lines, worker/ 40%), checked to fail when they're breached;
a CycloneDX SBOM of production dependencies for each main build, shown on the run page as the sbom-cyclonedx artifact and kept 90 days.
Fixed a flaky integration test (failed 1 in 6 runs under load before the fix, 0 in 10 after). The helper treated a worker as ready after its first heartbeat, before its WebSocket connected. It now waits until the server accepts a probe command, and cleanup can no longer hide a test's real error.
Phase 3: done, except Node 22, which waits until production moves to it.
**#52 is merged and deployed as `1474b0a`.** It adds:
- worker unit tests (7);
- coverage floors (`lib/` 90% of lines, `worker/` 40%), checked to fail when they're breached;
- a CycloneDX SBOM of production dependencies for each `main` build, shown on the run page as the `sbom-cyclonedx` artifact and kept 90 days.
**Fixed a flaky integration test** (failed 1 in 6 runs under load before the fix, 0 in 10 after). The helper treated a worker as ready after its first heartbeat, before its WebSocket connected. It now waits until the server accepts a probe command, and cleanup can no longer hide a test's real error.
**Phase 3:** done, except Node 22, which waits until production moves to it.
**Phase 4:**
- [x] gitleaks, actionlint, shellcheck
- [x] SBOM
- [ ] semgrep (local dry run needs user approval)
- [ ] Renovate (needs a bot account: user decision)
Gandalf CI parity is filed as LotusGuild/gandalf#55, for the Gandalf session.
#53 (phase 4): semgrep is in the Scan job (JavaScript, Node.js, Express, secrets and security-audit packs). The only finding was a false positive, which is suppressed with a reason.
#54 (phase 6): worker deploys are automated. The Deploy worker job runs after Deploy when worker code or dependencies have changed. It calls a signed hook on CT 153 that installs the exact sha, verifies via /healthzworker_versions, and restores the old files on failure. The first run deployed e167e2f cleanly.
Remaining:
Renovate: deferred by the user.
Phase 5 leftovers: stricter eslint, a web_template integrity check, automatic screenshots on UI PRs.
Node 22, once production moves to it.
**Phases 4 and 6 are done.**
- **#53 (phase 4):** semgrep is in the Scan job (JavaScript, Node.js, Express, secrets and security-audit packs). The only finding was a false positive, which is suppressed with a reason.
- **#54 (phase 6):** worker deploys are automated. The `Deploy worker` job runs after `Deploy` when worker code or dependencies have changed. It calls a signed hook on CT 153 that installs the exact sha, verifies via `/healthz` `worker_versions`, and restores the old files on failure. The first run deployed `e167e2f` cleanly.
**Remaining:**
- Renovate: deferred by the user.
- Phase 5 leftovers: stricter eslint, a web_template integrity check, automatic screenshots on UI PRs.
- Node 22, once production moves to it.
Phase 5 is done (#55, #56, #57), and with it every phase of this issue.
Stricter eslint with --max-warnings 0. Bug-prone patterns are now errors (==, unused or shadowed variables, eval, and others); the few existing violations are fixed.
Design system integrity: the Scan job fails if public/web_template differs from upstream at the commit in its VERSION. Vendoring goes through scripts/sync-web-template.sh.
The design system is dash-free (web_template#3). Pulse is resynced, the dash check now covers the vendored copy too, and Playwright checks that no page renders a dash.
UI screenshots (before/after): on PRs that touch the UI, it runs the base branch and the PR side by side with the same seeded data and uploads one comparison image per page, for desktop and phone.
Worker deploys now trigger only on worker/ or lockfile changes, so a package.json script change no longer restarts the worker.
npm audit retries only when the registry itself errors (it returned a spurious 400 once); real advisories still fail at once.
Final pipeline: lint, unit tests and coverage, npm audit and SBOM, scan (gitleaks, actionlint, shellcheck, design system, semgrep), integration, UI (desktop and phone), then deploy the server and deploy the worker. Both deploys pin the exact commit, verify it's running, and roll back on failure. Six checks are required on main.
Deferred:
Renovate, by user decision.
Node 22 in CI, once production moves to it.
Other repos: CI parity for Gandalf is gandalf#55; the design-system resync issues are gandalf#56, tinker_tickets#118 and devdesk#63.
Closing this issue. Reopen it, or file a new one, for the deferred items.
**Phase 5 is done (#55, #56, #57), and with it every phase of this issue.**
- **Stricter eslint** with `--max-warnings 0`. Bug-prone patterns are now errors (`==`, unused or shadowed variables, eval, and others); the few existing violations are fixed.
- **Design system integrity:** the Scan job fails if `public/web_template` differs from upstream at the commit in its `VERSION`. Vendoring goes through `scripts/sync-web-template.sh`.
- **The design system is dash-free** (web_template#3). Pulse is resynced, the dash check now covers the vendored copy too, and Playwright checks that no page renders a dash.
- **`UI screenshots (before/after)`:** on PRs that touch the UI, it runs the base branch and the PR side by side with the same seeded data and uploads one comparison image per page, for desktop and phone.
- **Worker deploys** now trigger only on `worker/` or lockfile changes, so a `package.json` script change no longer restarts the worker.
- **npm audit** retries only when the registry itself errors (it returned a spurious 400 once); real advisories still fail at once.
**Final pipeline:** lint, unit tests and coverage, npm audit and SBOM, scan (gitleaks, actionlint, shellcheck, design system, semgrep), integration, UI (desktop and phone), then deploy the server and deploy the worker. Both deploys pin the exact commit, verify it's running, and roll back on failure. Six checks are required on `main`.
**Deferred:**
- Renovate, by user decision.
- Node 22 in CI, once production moves to it.
Other repos: CI parity for Gandalf is gandalf#55; the design-system resync issues are gandalf#56, tinker_tickets#118 and devdesk#63.
Closing this issue. Reopen it, or file a new one, for the deferred items.
Correction: my last comment said every phase was done. Checked against the original plan, these items are still open, so I'm reopening the issue.
Phase 2
Run the webhook listeners (CT 122 and CT 153) as a less privileged user, with sudo limited to restarting the service.
Replay protection goes beyond timestamps: the requests still use plain HTTP on the LAN. That needs nonces, plus TLS or a source-address restriction to the runner.
Phase 3
The app-factory refactor (replaced for now by the black-box integration tests).
Custom semgrep rules (exec with user input, vm misuse, unescaped innerHTML).
Renovate (deferred by the user).
Attach the SBOM to the deploy tag (it's a run artifact today).
Phase 5
eslint-plugin-security.
Lint public/assets with browser globals.
Post the before/after screenshots as a PR comment and add a needs-visual-approval label (they're an artifact today).
Phase 6
Show the worker version in the Workers tab (UI).
**Correction:** my last comment said every phase was done. Checked against the original plan, these items are still open, so I'm reopening the issue.
**Phase 2**
- [ ] Run the webhook listeners (CT 122 and CT 153) as a less privileged user, with sudo limited to restarting the service.
- [ ] Replay protection goes beyond timestamps: the requests still use plain HTTP on the LAN. That needs nonces, plus TLS or a source-address restriction to the runner.
**Phase 3**
- [ ] The app-factory refactor (replaced for now by the black-box integration tests).
- [ ] Workflow engine tests: goto, conditions, prompts, abort.
- [ ] Scheduler tests.
- [ ] Node 22 in the matrix.
**Phase 4**
- [ ] Dependency and licence review on PRs.
- [ ] `npm audit signatures`.
- [ ] zizmor.
- [ ] Custom semgrep rules (exec with user input, vm misuse, unescaped `innerHTML`).
- [ ] Renovate (deferred by the user).
- [ ] Attach the SBOM to the deploy tag (it's a run artifact today).
**Phase 5**
- [ ] eslint-plugin-security.
- [ ] Lint `public/assets` with browser globals.
- [ ] Post the before/after screenshots as a PR comment and add a `needs-visual-approval` label (they're an artifact today).
**Phase 6**
- [ ] Show the worker version in the Workers tab (UI).
Source IP allowlist. Both Pulse hooks now require a valid HMAC and source IP 10.10.10.70 (the CI runner), on top of the existing timestamp replay protection. A probe from another LAN host was refused, and a CI rerun still deployed. Documented in the README (#58).
Non-root webhook listeners: dropped by decision. Both Pulse services run as root, so a deploy user that can write their code and restart them would effectively be root anyway. Real isolation would mean running the services under their own users. On the worker, that would change what Gandalf's commands run as. Not worth it for this setup.
TLS on the hooks: still plain HTTP on the LAN. With HMAC, timestamps and the IP allowlist in place, an observer can't forge a request or replay one usefully.
**Phase 2 webhook hardening:**
- [x] **Source IP allowlist.** Both Pulse hooks now require a valid HMAC **and** source IP 10.10.10.70 (the CI runner), on top of the existing timestamp replay protection. A probe from another LAN host was refused, and a CI rerun still deployed. Documented in the README (#58).
- [ ] ~~Non-root webhook listeners~~: **dropped by decision.** Both Pulse services run as root, so a deploy user that can write their code and restart them would effectively be root anyway. Real isolation would mean running the services under their own users. On the worker, that would change what Gandalf's commands run as. Not worth it for this setup.
- TLS on the hooks: still plain HTTP on the LAN. With HMAC, timestamps and the IP allowlist in place, an observer can't forge a request or replay one usefully.
Workflow engine and scheduler tests (#59). 16 integration tests. The known bugs (#8, #20, #9, and the cron 500) are written as test.failing.
Custom semgrep rules (#63)..semgrep/pulse.yml covers: no vm/eval, no shell in the server, no unescaped innerHTML values. The rules' own test cases run in CI with semgrep --test.
Browser JS lint. Already in place via public/.eslintrc.json (browser globals), and --max-warnings 0 makes its warnings fatal.
Workers tab shows each worker's version (#64), so phase 6 is complete. This was also the first real run of the before/after screenshot job, which passed.
Security fix (#60, recorded in #62). Conditions use a safe evaluator, and Pulse is admin-only.
Still open:
zizmor and eslint-plugin-security (new tools, which need approval to install)
dependency and licence review, and npm audit signatures
attaching the SBOM to the deploy tag
posting the screenshots as a PR comment
the app-factory refactor
Node 22
Renovate (deferred)
**Progress:**
- [x] **Workflow engine and scheduler tests (#59).** 16 integration tests. The known bugs (#8, #20, #9, and the cron 500) are written as `test.failing`.
- [x] **Custom semgrep rules (#63).** `.semgrep/pulse.yml` covers: no vm/eval, no shell in the server, no unescaped `innerHTML` values. The rules' own test cases run in CI with `semgrep --test`.
- [x] **Browser JS lint.** Already in place via `public/.eslintrc.json` (browser globals), and `--max-warnings 0` makes its warnings fatal.
- [x] **Workers tab shows each worker's version (#64), so phase 6 is complete.** This was also the first real run of the before/after screenshot job, which passed.
- [x] **Timeouts on every CI job (#61).**
- [x] **Security fix (#60, recorded in #62).** Conditions use a safe evaluator, and Pulse is admin-only.
**Still open:**
- zizmor and eslint-plugin-security (new tools, which need approval to install)
- dependency and licence review, and `npm audit signatures`
- attaching the SBOM to the deploy tag
- posting the screenshots as a PR comment
- the app-factory refactor
- Node 22
- Renovate (deferred)
Tests on Node 22: a separate Test (Node 22) job. It isn't a required check, and deploy doesn't wait for it. It passes today.
npm audit signatures in the Security job: 470 registry signatures and 64 attestations verified.
Licence review of production dependencies (scripts/ci/licenses.js): it checks against an allowlist and handles SPDX OR and AND expressions. All 105 packages pass.
Flaky unit test fixed (#82). The cancel_command test sometimes read an empty pid file. It had blocked the deploys of #80 and #81.
Still open:
attaching the SBOM to a deploy tag (needs a decision on tagging each deploy);
posting screenshots as a PR comment (needs a token that can comment);
the app-factory refactor;
moving production to Node 22;
Renovate (deferred).
**Progress (#86):**
- [x] **Tests on Node 22:** a separate `Test (Node 22)` job. It isn't a required check, and deploy doesn't wait for it. It passes today.
- [x] **`npm audit signatures`** in the Security job: 470 registry signatures and 64 attestations verified.
- [x] **Licence review of production dependencies** (`scripts/ci/licenses.js`): it checks against an allowlist and handles SPDX `OR` and `AND` expressions. All 105 packages pass.
- [x] **Flaky unit test fixed (#82).** The `cancel_command` test sometimes read an empty pid file. It had blocked the deploys of #80 and #81.
**Still open:**
- attaching the SBOM to a deploy tag (needs a decision on tagging each deploy);
- posting screenshots as a PR comment (needs a token that can comment);
- the app-factory refactor;
- moving production to Node 22;
- Renovate (deferred).
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.
Tracking issue for a full rework of Pulse's CI/CD pipeline. The goals: nothing reaches production unless it is tested; tests catch real regressions in
server.jsand the worker; security problems are caught in CI rather than in production; and a deploy can be verified and rolled back.Current state (audited 2026-11-22)
Pipeline
lint.ymlneeds: [js-lint]only. Tests and npm audit run in separate workflows, so a merge that fails tests still deploys. It installs eslint withnpm install --save-dev eslint@8, which ignores the lockfile and modifiespackage.jsonmid-run. The Matrix alert only fires when lint fails.test.ymlnpm installthenjest --coveragenpm install, notnpm ci. There is no coverage threshold. Coverage coverslib/only:server.js(about 2,000 lines, all routes, the WebSocket handling, the workflow engine and the scheduler) has no tests.security.ymlnpm audit --audit-level=high, weekly cronAcross all three:
actions/checkout@v3), not by commit SHA.permissions:block. The deploy job asks forcontents: write.concurrency:control, so two quick merges can deploy at the same time.lintonly.Deploy (
/usr/local/bin/pulse_deploy.shon CT 122, triggered by the webhook)git reset --hard origin/main. It deploys whatevermainis when it runs, not the commit CI tested.npm install --production. That isn't reproducible, can rewrite the lockfile, and--productionis deprecated in favour of--omit=dev.systemctl is-activeafter 2 s. There's no HTTP or WebSocket check and no rollback: a bad build stays down until someone fixes it..envto a fixed path in/tmp.{"ref":"refs/heads/main"}, so the HMAC signature never changes. Anyone who sees one request on the LAN (plain HTTP to:9000) can replay it to restart Pulse at will. The listener runs as root.Plan
Phase 1: Gate deploys and make builds reproducible (urgent, small)
ci.ymlwith jobslint,test,auditanddeploy, where deployneeds: [lint, test, audit]and runs only on push tomain. Alternatively, keep separate files and gate deploy withworkflow_run.npm cieverywhere, use the lockfile's eslint, and add annpm run lintscript.actions/setup-nodepinned to the production Node major version (20), with an npm cache.permissions: contents: readat the top and grant more per job only where needed. Addconcurrency: deploy-productionwithcancel-in-progress: false.main, and when a deploy succeeds or fails.lint,testandaudit.Phase 2: Deploy safety
pulse_deploy.shchecks out exactly that SHA (git fetch+git checkout --detach <sha>) and refuses anything that isn't onorigin/main.{sha, timestamp, nonce}, reject timestamps more than 5 minutes old, and remember recent nonces. Move the webhook behind TLS or restrict it to the runner's address.npm ci --omit=dev. Back up.envwithmktempand mode 600.GET /healthzthat returns the version, the git SHA, DB connectivity and the number of connected workers. The deploy polls it for 30 s, and CI checks it remotely too.npm ci, restart, and alert.deploy-*tag only after the health check passes.systemctl restart pulse.Phase 3: Real tests
server.jsinto an app factory (createApp({ pool, env })), so tests can start it on a random port without starting the background timers.supertestandws. Add the existing ad-hoc harnesses from #41/#42 as proper tests:POST /api/internal/command, then polling/api/internal/executions/:idgivescompletedand stdout, orfailed.Phase 4: Security scanning
execwith user input, novmmisuse, no unescapedinnerHTML).npm audit signatures.${{ github.* }}inrun:).Phase 5: Accuracy and UI review automation
—/–or their escapes appear in Pulse-owned files (house style).eslint-plugin-security, and lint the browser JS (public/assets) with browser globals.public/web_template/matches theVERSIONit claims (no hand edits).views/,public/assets/orlib/render.js, CI starts the demo instance (scripts/demo/: MariaDB, server, 3 workers, seed), captures main and the PR with Playwright, posts a before/after image as a PR comment, and labels the PRneeds-visual-approval. This automates the current rule that UI changes need screenshot approval.Phase 6: Workers in the pipeline (with #40)
worker/worker.jsto CT 153 through the existing pve-infra webhook, or a Pulse-side hook, at the same tested SHA./healthzand the Workers tab show drift.Suggested order
Phase 1 first: it's small, and it closes the "untested code reaches production" gap. Then Phase 2 (safe deploys), then Phase 3 (tests), which is the biggest gain in correctness. Phases 4 to 6 can run in parallel after that. Each phase lands as its own PR or PRs.
Related: #40 (worker deployment), #28 (docs).
Progress (2026-11-22)
Phase 1: done (#46)
ci.yml; deploy waits for lint, test and audit.npm cieverywhere, Node 20, actions pinned to commit SHAs.proxy-addr(critical) andbody-parser/follow-redirects(high), now fixed.Phase 2: done (#47)
GET /healthzreports the running sha, the database and connected workers.deploy/pulse_deploy.shis versioned and installed on CT 122 (old copy kept as.bak-2026-11-22). It deploys exactly the signed sha, rejects stale or replayed requests and off-main commits, usesnpm ci --omit=dev, waits for/healthz, and rolls back automatically.First gate catch: on #48's merge,
setup-nodefailed transiently with no error, and deploy was correctly skipped. The rerun is in progress. If this recurs, dropcache: npmor add a retry.Addition to Phase 5: frontend and UI/UX testing in the same pipeline (requested)
Playwright is already available, so:
uijob toci.ymlthat runs alongsidetest:scripts/demo/seed.py.tests/ui/*.spec.js):uia required check, so it gates deploy likelint,testandaudit.Phase 5: the Playwright UI job is live (#49), and deploys now wait for it.
UI (playwright)job: runs the real server and 3 real workers (worker auth enforced) against MariaDB, then 30 tests on desktop and a Pixel 7 viewport. Coverage: pages, Quick Command end to end, workflow create and run, live WebSocket updates, the 401/403 auth paths, and mobile overflow. A shared fixture fails any test on a page error, console error or failed request. Takes about 1.5 minutes.1d5b8cd, tag on main run 142./healthzwas healthy and the worker reconnected.Runner findings (affect every repo):
bridgenetwork, soservices:containers can't be reached by name. MariaDB is now installed inside the job container instead.act-toolcachevolume, so concurrentactions/setup-noderuns corrupt each other. That caused both of today's "setup-node" failures. Jobs now take Node from a pinned image (node:20-bookworm), and the UI job uses the Playwright image (Node 26).Still to do in phase 5:
CI / UI (playwright) (push)a required check (user, branch protection)Phase 3: the integration job is live (#50), deployed as
4f32bd1.Integration (api)runs the real server and 3 workers on Node 20 against MariaDB. 20 black-box tests cover the Gandalf contract, HTTP and WebSocket auth (including forged results), and reliability (crash, capacity, abort, offline status). About 12 s.Bug found: since #42, a disconnected worker was never marked offline. It's fixed in the same PR.
Required checks on
mainare now: Lint, Test, Security, Integration, UI.Still open from phase 3:
worker/worker.jsspawn, timeout and capacity logic, without a server)I swapped the planned app-factory refactor for black-box tests, which cover the same contracts without touching
server.js. A refactor can come later if unit-level server tests ever need it.Phase 4: the scan job is live (#51), deployed as
15f8ec4.Scan (secrets, workflows, shell)runs on every push and PR, and it's now a required check:run:scripts;*.sh.The tool downloads are pinned and checked against SHA-256 sums.
Still open in phase 4:
npm sbom)#52 is merged and deployed as
1474b0a. It adds:lib/90% of lines,worker/40%), checked to fail when they're breached;mainbuild, shown on the run page as thesbom-cyclonedxartifact and kept 90 days.Fixed a flaky integration test (failed 1 in 6 runs under load before the fix, 0 in 10 after). The helper treated a worker as ready after its first heartbeat, before its WebSocket connected. It now waits until the server accepts a probe command, and cleanup can no longer hide a test's real error.
Phase 3: done, except Node 22, which waits until production moves to it.
Phase 4:
Gandalf CI parity is filed as LotusGuild/gandalf#55, for the Gandalf session.
Phases 4 and 6 are done.
Deploy workerjob runs afterDeploywhen worker code or dependencies have changed. It calls a signed hook on CT 153 that installs the exact sha, verifies via/healthzworker_versions, and restores the old files on failure. The first run deployede167e2fcleanly.Remaining:
Phase 5 is done (#55, #56, #57), and with it every phase of this issue.
--max-warnings 0. Bug-prone patterns are now errors (==, unused or shadowed variables, eval, and others); the few existing violations are fixed.public/web_templatediffers from upstream at the commit in itsVERSION. Vendoring goes throughscripts/sync-web-template.sh.UI screenshots (before/after): on PRs that touch the UI, it runs the base branch and the PR side by side with the same seeded data and uploads one comparison image per page, for desktop and phone.worker/or lockfile changes, so apackage.jsonscript change no longer restarts the worker.Final pipeline: lint, unit tests and coverage, npm audit and SBOM, scan (gitleaks, actionlint, shellcheck, design system, semgrep), integration, UI (desktop and phone), then deploy the server and deploy the worker. Both deploys pin the exact commit, verify it's running, and roll back on failure. Six checks are required on
main.Deferred:
Other repos: CI parity for Gandalf is gandalf#55; the design-system resync issues are gandalf#56, tinker_tickets#118 and devdesk#63.
Closing this issue. Reopen it, or file a new one, for the deferred items.
Correction: my last comment said every phase was done. Checked against the original plan, these items are still open, so I'm reopening the issue.
Phase 2
Phase 3
Phase 4
npm audit signatures.innerHTML).Phase 5
public/assetswith browser globals.needs-visual-approvallabel (they're an artifact today).Phase 6
Phase 2 webhook hardening:
Non-root webhook listeners: dropped by decision. Both Pulse services run as root, so a deploy user that can write their code and restart them would effectively be root anyway. Real isolation would mean running the services under their own users. On the worker, that would change what Gandalf's commands run as. Not worth it for this setup.Progress:
test.failing..semgrep/pulse.ymlcovers: no vm/eval, no shell in the server, no unescapedinnerHTMLvalues. The rules' own test cases run in CI withsemgrep --test.public/.eslintrc.json(browser globals), and--max-warnings 0makes its warnings fatal.Still open:
npm audit signaturesProgress (#86):
Test (Node 22)job. It isn't a required check, and deploy doesn't wait for it. It passes today.npm audit signaturesin the Security job: 470 registry signatures and 64 attestations verified.scripts/ci/licenses.js): it checks against an allowlist and handles SPDXORandANDexpressions. All 105 packages pass.cancel_commandtest sometimes read an empty pid file. It had blocked the deploys of #80 and #81.Still open: