- worker/worker.js exports PulseWorker and starts only when run directly
(no behaviour change for the service; CT 153 needs no redeploy).
- tests/worker.test.js: success, exit code and stderr, timeout kill,
capacity rejection, slot release after failure, ping/pong, no sends
while disconnected.
- jest coverage floors (ratchet at today's levels): lib/ 90% lines and
statements, 80% branches and functions; worker/ 40%.
- The audit job writes a CycloneDX SBOM of production dependencies and
keeps it 90 days for each main build.
Part of #45 phases 3 and 4.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
All three pass on main today: gitleaks found no leaks in 88 commits, and
actionlint's one warning (an unused loop variable in the deploy health
check) is fixed here. Tool downloads are pinned to a version and verified
by SHA-256. Deploy now also waits for the scan. Part of #45 phase 4.
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>
New required-to-be job `UI (playwright)` (#45 phase 5): the official
Playwright image with a MariaDB service container. scripts/ci/ui-stack.sh
starts the real server and three workers (WORKER_AUTH_ENFORCE=1), then
tests/ui/ runs 30 tests on desktop and a phone viewport:
- every page loads with no page errors, console errors or failed requests
(enforced by a shared fixture for every test)
- quick commands run on a worker and their output and status show in
Executions; multi-worker mode; failing commands show as failed
- workflows are created and run from the UI and complete on all workers
- Executions updates live over the authenticated browser WebSocket
- no SSO identity: 401 page and API; wrong group: 403
- every page fits a phone screen
External requests are blocked in tests so SSO headers never leave the
machine. Deploy now also waits for the UI job. The API and execution rate
limits can be raised with PULSE_API_RATE_MAX / PULSE_EXEC_RATE_MAX for
test stacks; production defaults are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#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>
The deploy job lived in lint.yml and needed only eslint, while jest and
npm audit ran in separate workflows. A merge that failed its tests still
deployed to production. (#45 phase 1)
- Combine everything into .gitea/workflows/ci.yml with jobs lint, test,
audit, deploy and notify. Deploy needs all three checks and runs only
on push to main.
- Builds are reproducible: npm ci everywhere, eslint from the lockfile
(new `npm run lint`), and setup-node pinned to Node 20 (production).
- Actions are pinned to full commit SHAs, with the version in a comment,
following tinker_tickets.
- Workflow permissions default to contents: read; only deploy can write
(for its tag). A deploy-production concurrency group queues deploys
instead of running two at once. Superseded branch runs are cancelled.
- The deploy payload now carries the sha and a timestamp, so signatures
differ per deploy (the server verifies them in phase 2). After the
webhook, CI waits until Pulse is serving again before tagging.
- The Matrix alert now fires for any failed job on main, for the weekly
audit, and for every successful deploy.
- New lint step: fail on em or en dashes in Pulse-owned files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace every em dash and en dash outside user-visible UI text with a
colon, comma, hyphen or "to". The UI strings and the vendored
web_template are handled separately.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Any client that could reach :8080 got a WebSocket connection. Every
connection started as a browser client and received every broadcast.
worker_connect accepted a missing api_key, so anyone could register under
an existing worker's name and receive its commands. command_result was
accepted from any connection, so execution logs could be forged.
- Classify each upgrade in verifyClient (lib/wsauth.js). A request is:
- browser: a trusted-proxy Authelia identity in an allowed group;
- worker: Authorization: Bearer <WORKER_API_KEY>;
- pending: neither, allowed only while WORKER_AUTH_ENFORCE is off;
- rejected (401): everything else, and always for a wrong key.
- Only browser connections receive broadcasts. A pending connection may
send only worker_connect and is closed after 30 s if it doesn't identify.
- worker_connect requires the key. A keyless worker is allowed with a
warning until WORKER_AUTH_ENFORCE=1, so existing workers keep working
until they are updated.
- Record which worker each command was sent to. command_result is accepted
only from that worker (matched by DB id, so a reconnect mid-command
still works) and only once. pong no longer trusts a client-supplied id.
- Worker, heartbeat and Gandalf keys use a constant-time compare. Log an
error at startup if WORKER_API_KEY is unset.
- The worker sends its key at the handshake and in worker_connect.
Closes#38
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
authenticateSSO and authenticatePage took the user and groups straight
from the Remote-* headers, and the server listens on every interface, so
any LAN host could connect directly, claim any user and group, and run
commands on the workers. It could also write whatever it claimed into the
users table.
Add TRUSTED_PROXIES (addresses or CIDR ranges) and ignore the identity
headers unless the TCP peer is on the list. The peer address is used
rather than a forwarding header, which a client could forge. It fails
closed: unset means no SSO login succeeds, with a startup warning.
Rejected attempts are logged with their source. Worker and Gandalf
API-key routes are unchanged.
Closes#37
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Fix design-system class names that do not exist in base.css (.lt-alert--error,
.lt-form-hint); add shared .lt-modal-lg, .lt-field-error and .is-invalid rules
- Remove public/index.html and the public/base.js symlink
- package.json: start script, correct main
- README: vendored design system, Web UI section, new env vars, read-only dev mode
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HamVMDrA8RqhyxmUHgiqRp
- §5: Section headers now ╠═══ TITLE ═══╣ (was ═══ TITLE ═══)
- §8+§18: Replace inline-style showTerminalNotification() with lt.toast.*
delegate wrapper; load base.js from /base.js
- §12: Fix --text-muted #008822→#00bb33 (WCAG AA contrast)
base.js symlinked from web_template into public/ so lt.* is available.
showTerminalNotification() is kept as a thin wrapper so all existing
call sites continue to work unchanged.
README: Remove completed pending items (toast, text-muted, position)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Added ability to execute commands on multiple workers simultaneously:
- Added execution mode selector (Single/Multiple Workers)
- Multi-worker mode with checkbox list for worker selection
- Helper buttons: Select All, Online Only, Clear All
- Sequential execution across selected workers
- Results summary showing success/fail count per worker
- Updated command history to track multi-worker executions
- Terminal beep feedback based on overall success/failure
- Maintained backward compatibility with single worker mode
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>