- 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>
JavaScript, Node.js, Express, secrets and security-audit rule packs, with
--error so findings fail the check. Dry run on main: no findings from the
first four packs; security-audit flagged one false positive (the demo seed
script's urlopen of a fixed loopback URL), suppressed on that line with the
reason. Part of #45 phase 4.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Under load a new worker's first heartbeat marked it online before its
WebSocket had connected, so a test's first command was refused, and the
cleanup in finally then threw its own error and hid the real one.
startWorker now waits until the server accepts a probe command for the
worker, and cleanup never throws (offline status has its own test).
Reproduced 1 in 6 under UI-test load before; 0 in 10 after.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 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>
The runner uses Docker's default bridge network, so the mariadb service
hostname never resolved. It also shares one tool cache volume between
concurrent jobs: parallel setup-node runs overwrote each other's Node
(the earlier <nil> failure and today's missing npm package.json).
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 dash check's own pattern contained the literal entities it searches
for. Use &[mn]dash; so the check doesn't flag itself.
- npm audit fix (lockfile only, no major bumps): proxy-addr 2.0.8
(critical), body-parser 2.4.0 (high), follow-redirects 1.16.3 (high,
used by the worker through axios), qs 6.17.1, ip-address. The remaining
glob/minimatch advisories are moderate, dev-only (jest) and need a
breaking upgrade, so they stay below the high threshold.
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 the remaining dashes users can see:
- error page titles and headings, and the browser tab title: "|" or ":";
- the footer: "PULSE | TDS v1.2";
- the 401 message and two toasts: sentence breaks or a comma;
- the quick-command history and success line: "|";
- empty table cells: "-";
- the compare hint: "2 to 5".
No layout or behaviour changes.
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>
Quick, scheduled and Gandalf commands relied entirely on the worker sending
a command_result. If the worker was at capacity, disconnected or restarted,
the execution stayed 'running' forever (#7). Failed commands also lost the
worker's error message (#14).
- Direct commands now get a server-side timeout: the command timeout plus
30 s. When it expires, the execution fails with a command_result entry
carrying the error, which the UI already renders and Gandalf treats as
'failed' and retries.
- When a worker socket closes, every command sent over it fails at once.
Pending workflow step waits resolve as failures, so the engine moves on.
- Every 5 minutes, a backstop sweep fails 'running' executions past
EXECUTION_MAX_MINUTES + 10 that nothing is tracking.
- updateExecutionStatus only changes a 'running' execution and reports
whether it did. A late result, or the engine finishing after an abort,
can no longer flip a failed execution to completed or fire a second
webhook.
- Aborting a quick command clears its timeout.
- command_result keeps error, exit_code, signal and timed_out in the log,
the broadcast and the workflow step result.
- The worker reports "at capacity" as a failed result instead of staying
silent, and includes exit_code, signal and timed_out on failures.
- Fix: after a worker reconnected, the old socket closing removed the new
socket's mapping and marked the worker offline, so commands got "Worker
not connected" until the next heartbeat.
Closes#7Closes#14
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>
mysql2 3.24 (pulled in by the audit fix in #35) returns MariaDB JSON columns as
JS objects. GET /api/internal/executions/:id and GET /api/workflows/:id still
called JSON.parse on the value, threw, and silently returned [] / {}. This broke
Gandalf's relay checks (false 'PBS unreachable' ticket) and the workflow edit
modal. Guard both sites with the same typeof check already used by
GET /api/executions/:id.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HamVMDrA8RqhyxmUHgiqRp
- 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
- Dashboard, Workers, Workflows, Executions, Quick Command, Scheduler pages on the
shared layout, all behaviour via Pulse delegated actions (no inline handlers)
- Executions: server-driven Manual/Automated views, compare mode, detail modal with all
log types, ?open= deep link, cross-page re-run via sessionStorage
- Workflows: run modal (dry-run available for every workflow), create modal pre-filled
with the example definition
- Fix EJS comment in page-header partial that broke rendering
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HamVMDrA8RqhyxmUHgiqRp
- lint.yml: add notify-failure Matrix alert job; add Tag deployed commit
step to deploy job with deploy-YYYY.MM.DD-N tagging via Gitea API
- package.json: add --coverage flag to jest test script
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add tests/.eslintrc.json to declare jest globals (describe/test/expect)
- Fix no-useless-escape in lib/utils.js regex character class
- Run npm audit fix: updated path-to-regexp and qs (1 high, 1 moderate fixed)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Extract validateWebhookUrl, applyParams, evalCondition, calculateNextRun
to lib/utils.js so they can be tested without DB connection
- Fix cron-parser v5 API: parseExpression → CronExpressionParser.parse
- Add 31 jest tests covering all four utility functions
- Add test.yml CI workflow running jest on every push/PR
- Add jest devDependency
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add deploy job gated on js-lint passing
- Deploy triggers pulse-deploy webhook on main branch only
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>