Commit Graph
11 Commits
Author SHA1 Message Date
jaredandClaude Opus 5.5 cb2c7a10fd Docs: correct setup, workflow and scheduler reference, env vars, schema (#28)
CI / Lint (eslint) (pull_request) Successful in 25s
CI / Test (jest) (pull_request) Failing after 23s
CI / Security (npm audit) (pull_request) Successful in 10s
CI / Integration (api) (pull_request) Successful in 2m24s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m49s
CI / UI screenshots (before/after) (pull_request) Successful in 17s
CI / UI (playwright) (pull_request) Successful in 1m52s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
- Server setup: npm ci, .env from .env.example, /healthz check; no
  SECRET_KEY (nothing reads it).
- Worker setup was wrong (worker.js lives in worker/, and the deps come
  from the root manifests): copy worker.js plus package.json and
  package-lock.json, npm ci --omit=dev, .env from worker/.env.example;
  updates then come through the worker deploy hook.
- Workflows: replaces "Future Feature" with a reference for every step
  type and field, the condition language, params, goto/end, dry run,
  abort, webhooks and the time limit, with a worked example. New
  Scheduler section.
- Environment variables: complete tables for server and worker,
  including GANDALF_API_KEY, EXECUTION_MAX_MINUTES, HOST, rate limits.
- Database schema: the real tables and columns, scheduled_commands
  included.
- Troubleshooting: stuck executions now fail on their own; how to clear.
- Removed the stale "Recent Updates" and "Future Enhancements" lists.
- .env.example and worker/.env.example; package.json license is MIT, like
  LICENSE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 12:11:45 -05:00
jaredandClaude Opus 5.5 789e5651c8 Worker memory: report available memory, not free memory (#30)
CI / Test (jest) (pull_request) Successful in 19s
CI / Lint (eslint) (pull_request) Successful in 21s
CI / Security (npm audit) (pull_request) Successful in 11s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m54s
CI / Integration (api) (pull_request) Successful in 2m36s
CI / UI (playwright) (pull_request) Successful in 2m15s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 2m29s
os.freemem() leaves out the page cache, so a healthy Linux box looks full:
the production worker (CT 153, 512 MB) has 4 MB free but 449 MB
available, and showed as 99% used instead of about 12%.

- worker: heartbeat metadata adds availableMem from MemAvailable in
  /proc/meminfo (falls back to os.freemem()); freeMem stays for old
  servers.
- Workers tab and dashboard compute used memory from availableMem when
  present, from freeMem for workers that predate it.
- Unit tests for the meminfo parsing and the fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 11:55:25 -05:00
jared 986791ae20 Merge remote-tracking branch 'origin/main' into backend-bugs
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 35s
CI / Test (jest) (push) Successful in 39s
CI / Security (npm audit) (push) Successful in 21s
CI / Integration (api) (push) Canceled after 3m54s
CI / Scan (secrets, workflows, shell) (push) Canceled after 3m18s
CI / UI (playwright) (push) Canceled after 0s
CI / Deploy (push) Canceled after 0s
CI / Lint (eslint) (pull_request) Canceled after 0s
CI / Deploy worker (push) Canceled after 0s
CI / Test (jest) (pull_request) Canceled after 0s
CI / Notify (push) Canceled after 0s
CI / Security (npm audit) (pull_request) Canceled after 0s
CI / Integration (api) (pull_request) Canceled after 0s
CI / Scan (secrets, workflows, shell) (pull_request) Canceled after 0s
CI / UI (playwright) (pull_request) Canceled after 0s
CI / UI screenshots (before/after) (pull_request) Canceled after 0s
CI / Deploy (pull_request) Canceled after 0s
CI / Deploy worker (pull_request) Canceled after 0s
CI / Notify (pull_request) Canceled after 0s
2026-11-23 00:27:00 -05:00
jaredandClaude Opus 5.5 397f4dd778 Worker: keepalive, reconnect backoff, no crash loop at startup (#1, #29)
- #1: the worker pings the server every 30 s over the WebSocket; if the
  previous ping got no pong, the connection is dead (server restart or
  network drop without a close) and is terminated so it reconnects. The
  ws server answers pings itself, so the server needs no change.
- #29: reconnects back off from 1 s doubling to 60 s with up to 20%
  jitter, reset on a successful connection; a failed first heartbeat is
  logged and retried instead of exiting into a systemd crash loop.
- stop() no longer schedules a reconnect.
- Tests: backoff bounds, missed pong terminates, pong keeps, startup with
  an unreachable server (unit and end to end). The #6 test now waits for
  the worker to show offline before sending one command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 00:08:35 -05:00
jaredandClaude Opus 5.5 073114c92e Abort kills the command on the worker (#8 follow-up)
- worker: commands run with spawn in their own process group (same
  timeout, 10 MB output limit and result fields as exec). A new
  cancel_command message (by command_id, or every command of an
  execution) sends SIGTERM to the group, then SIGKILL after 5 s; the
  result reports cancelled: true. Old workers ignore the message.
- server: the abort route sends cancel_command to the worker running each
  of the execution's commands.
- Tests: the whole process tree dies on cancel (a background child too),
  execution-wide cancel leaves other executions alone, and end to end an
  aborted quick command's process is gone from the worker. Liveness
  checks treat zombies as dead (an orphan waits to be reaped).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:59:50 -05:00
jaredandClaude Opus 5.5 235d9240c0 CI: eslint-plugin-security and zizmor; harden the workflow
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 23s
CI / Test (jest) (push) Successful in 22s
CI / Security (npm audit) (push) Successful in 14s
CI / Scan (secrets, workflows, shell) (push) Failing after 18s
CI / Integration (api) (push) Successful in 2m43s
CI / Lint (eslint) (pull_request) Successful in 17s
CI / Test (jest) (pull_request) Successful in 18s
CI / Security (npm audit) (pull_request) Successful in 13s
CI / UI (playwright) (push) Successful in 3m0s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Skipped
CI / Scan (secrets, workflows, shell) (pull_request) Failing after 14s
CI / Integration (api) (pull_request) Successful in 2m24s
CI / UI (playwright) (pull_request) Successful in 2m16s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 2m18s
- eslint-plugin-security 4.2.1 (recommended-legacy) with
  detect-object-injection off (it flags every obj[key]) and file/regex
  rules off for CI scripts and tests. The remaining hits were false
  positives with a one-line reason each (fixed page names, the worker's
  own directory, a null check), plus one real tidy-up: the condition
  tokenizer's number regex is now two flat patterns with no backtracking,
  and malformed numbers like 1.2.3 are refused.
- zizmor 1.32.0 in the Scan job. Its findings are fixed:
  persist-credentials: false on every checkout (no job pushes), container
  images pinned by digest (tag kept in the reference), and the deploy tag
  step takes github.* values through env instead of template expansion.
  Left as is: secrets-outside-env (auditor persona; Gitea has no
  deployment environments).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:45:35 -05:00
jaredandClaude Opus 5.5 ea939d4430 Worker deploys from CI, with version reporting (#40)
CI / Lint (eslint) (push) Successful in 14s
CI / Test (jest) (push) Successful in 18s
CI / Security (npm audit) (push) Successful in 12s
CI / Integration (api) (push) Successful in 1m14s
CI / Scan (secrets, workflows, shell) (push) Successful in 1m29s
CI / Lint (eslint) (pull_request) Successful in 19s
CI / Test (jest) (pull_request) Successful in 13s
CI / Security (npm audit) (pull_request) Successful in 7s
CI / UI (playwright) (push) Successful in 1m43s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Skipped
CI / Integration (api) (pull_request) Successful in 1m51s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 2m20s
CI / UI (playwright) (pull_request) Successful in 1m37s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
- 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>
2026-11-22 16:51:24 -05:00
jaredandClaude Opus 5.5 38a6d1158d Worker unit tests, coverage floors, and an SBOM per main build
CI / Lint (eslint) (push) Successful in 17s
CI / Test (jest) (push) Successful in 18s
CI / Security (npm audit) (push) Failing after 12s
CI / Scan (secrets, workflows, shell) (push) Successful in 18s
CI / Integration (api) (push) Successful in 2m58s
CI / Lint (eslint) (pull_request) Successful in 24s
CI / Test (jest) (pull_request) Successful in 15s
CI / UI (playwright) (push) Successful in 3m11s
CI / Deploy (push) Skipped
CI / Notify (push) Skipped
CI / Security (npm audit) (pull_request) Failing after 12s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 15s
CI / Integration (api) (pull_request) Successful in 1m18s
CI / UI (playwright) (pull_request) Successful in 1m31s
CI / Deploy (pull_request) Skipped
CI / Notify (pull_request) Skipped
- 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>
2026-11-22 15:28:23 -05:00
jaredandClaude Opus 5.5 071b4072c2 Fail stuck executions, keep worker error details, guard terminal status
Security / JS Security (npm audit) (push) Failing after 19s
Lint / JS (eslint) (push) Successful in 21s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Lint / JS (eslint) (pull_request) Successful in 13s
Test / JS Tests (jest) (push) Successful in 18s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / JS Security (npm audit) (pull_request) Failing after 18s
Test / JS Tests (jest) (pull_request) Successful in 15s
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 #7
Closes #14

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:17:09 -05:00
jaredandClaude Opus 5.5 ac6c6c72c5 Authenticate WebSocket connections and bind command results to their worker
Security / JS Security (npm audit) (push) Failing after 16s
Lint / JS (eslint) (push) Successful in 18s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Test / JS Tests (jest) (push) Successful in 15s
Lint / JS (eslint) (pull_request) Successful in 13s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / JS Security (npm audit) (pull_request) Failing after 17s
Test / JS Tests (jest) (pull_request) Successful in 15s
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>
2026-11-22 01:07:18 -05:00
jaredandClaude Sonnet 4.6 2290d52f8b Fix prompt buttons, add command output to prompt steps, add worker to repo
- Fix onclick buttons broken by JSON.stringify double-quotes inside HTML
  attributes — use data-opt attribute + this.dataset.opt instead
- Track last command stdout in execution state when command_result arrives
- executePromptStep: include last command output in log entry and broadcast
  so users can review results alongside the question in the same view
- GET /api/executions/🆔 propagate output field to pending prompt response
- Add .prompt-output CSS class for scrollable terminal-style output block
- Fix MariaDB CAST(? AS JSON) → JSON_EXTRACT(?, '$') (MariaDB 10.11 compat)
- Add worker/worker.js to repo (deployed on pulse-worker-01 / LXC 153)
  Fix: worker was not echoing command_id back in result — resolvers always
  got undefined, causing every workflow step to timeout and fail

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 19:06:02 -04:00