jaredandClaude Opus 5.5 16a93f02be
CI / Test (jest) (pull_request) Successful in 22s
CI / Security (npm audit) (pull_request) Successful in 30s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m18s
CI / Integration (api) (pull_request) Successful in 2m16s
CI / UI screenshots (before/after) (pull_request) Successful in 15s
CI / Lint (eslint) (pull_request) Successful in 26s
CI / UI (playwright) (pull_request) Successful in 2m45s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI: a rerun of a main run no longer fails on its own deploy tag
A rerun keeps its run number, so "Tag deployed commit" tried to create
deploy-<date>-<run> again, got a conflict, and failed the Deploy job
after a successful deploy, which also skipped Deploy worker. The step
now accepts an existing tag when it marks the same commit, and fails
with the details when it marks another.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 22:52:02 -05:00
2026-10-03 00:16:58 -04:00

PULSE - Pipelined Unified Logic & Server Engine

Lint Test Security

A distributed workflow orchestration platform for managing and executing complex multi-step operations across server clusters through a retro terminal-themed web interface.

Security Notice: This repository is hosted on Gitea and is version-controlled. Never commit secrets, credentials, passwords, API keys, or any sensitive information to this repo. All sensitive configuration belongs exclusively in .env files which are listed in .gitignore and must never be committed. This includes database passwords, worker API keys, webhook secrets, and internal IP details.

Design System: web_template: shared CSS, JS, and layout patterns for all LotusGuild apps

Styling & Layout

PULSE uses the LotusGuild Terminal Design System. The design system is vendored into this repo at public/web_template/ (base.css, base.js, VERSION) and served from /web_template/*, so the app has no runtime dependency on a sibling checkout. public/web_template/VERSION records the design-system version, upstream short SHA, and sync date; asset URLs are cache-busted with it.

Update the vendored copy with:

scripts/sync-web-template.sh <path-to-web_template-checkout>

The script copies base.css/base.js as regular files (never symlinks) and rewrites VERSION. Never hand-edit public/web_template/: it is excluded from ESLint and overwritten on every sync. Pulse-local gaps in the design system live in public/assets/app.css (currently .lt-modal-lg, .lt-field-error, .is-invalid) and are candidates for upstreaming.

Reference documentation:

PULSE walkthrough: dashboard, workers, workflows, execution logs with an approval prompt, a multi-worker quick command and the command palette

Why this exists

I run a six-node Proxmox/Ceph cluster plus a pile of LXC containers. Day-to-day work is the same handful of questions asked of many machines: what is the disk usage everywhere, restart that service on one node, is it safe to proceed? SSH-ing into each box does not scale, and a full config-management system is more than I need. PULSE is a small orchestration layer: a server with a web UI, and a lightweight worker on each machine that executes what the server dispatches over a WebSocket. It adds what shell loops lack: multi-step workflows with conditions and human approval gates, scheduled commands, a full execution history, and an API that other tools call (GANDALF uses it to run network diagnostics).

flowchart LR
  user["Browser<br/>(Authelia SSO)"] -->|HTTPS| srv["PULSE server<br/>Express + EJS + WebSocket"]
  gd["GANDALF"] -->|internal API| srv
  srv --> db[("MariaDB<br/>workflows, executions,<br/>schedules")]
  srv <-->|"WebSocket<br/>commands / results / heartbeat"| w1["worker: node-01"]
  srv <-->|WebSocket| w2["worker: node-02"]
  srv <-->|WebSocket| w3["worker: node-03"]

Workflows are plain JSON with five step types: execute, prompt (pause for a human decision), wait, parse (pull KEY=VALUE lines from output into state) and route (branch on parsed state).

Dashboard: recent executions at a glance and live worker status.

Dashboard

Workers report system info, memory, load, uptime and task slots on every heartbeat:

Workers

Workflows are reusable multi-step jobs. The editor takes the JSON definition directly:

Workflow list Workflow editor
Workflows Workflow editor

Executions: full history with step-by-step logs, per-command output and durations.

Executions

Completed run with step logs A failed command, with its error
Execution detail Failed execution

Approval gates: a prompt step pauses the workflow until someone chooses an option (here, a rolling restart waits for a human to approve):

Awaiting approval

Quick Command runs a one-off command on one or many workers at once:

Compose Result
Quick command Quick command result

Scheduler runs commands on an interval or hourly schedule:

Scheduler

Command palette (Ctrl+K) and light theme:

Command palette Light theme
Command palette Dashboard, light theme

Screenshots are generated with Playwright against a throwaway local instance with three local workers running harmless commands (uptime, df, echo). See scripts/demo/.

Web UI

The UI is server-rendered with EJS. Every route renders views/pages/<page>.ejs into the shared chrome in views/layout.ejs (nav, header, WebSocket status dot, theme toggle, command palette).

Route Page View Page module
/ Dashboard views/pages/dashboard.ejs public/assets/pages/dashboard.js
/workers Workers views/pages/workers.ejs public/assets/pages/workers.js
/workflows Workflows views/pages/workflows.ejs public/assets/pages/workflows.js
/executions Executions views/pages/executions.ejs public/assets/pages/executions.js
/quick Quick Command views/pages/quick.ejs public/assets/pages/quick.js
/scheduler Scheduler views/pages/scheduler.ejs public/assets/pages/scheduler.js

Scripts load in a fixed order: /web_template/base.js → /assets/app.js → /assets/pages/<page>.js. app.js owns the shell (window.Pulse: action registry, event bus, Pulse.confirm, formatters, WebSocket, the single 30 s auto-refresh) and each page module registers itself with:

Pulse.registerPage({ name, init(), refresh(), onEvent(type, data) /* return true if handled */ });

Page modules never attach their own listeners for UI actions: they register handlers under their own action prefix (dash:, wk:, wf:, ex:, qc:, sc:) and the markup wires them up with data-action / data-change-action / data-input-action / data-submit-action attributes that app.js delegates. DOM ids are likewise prefixed per page. All dynamic strings go through Pulse.esc, and destructive actions use the themed Pulse.confirm (no native confirm()/alert()).

Content Security Policy: pages are served under a strict nonce-based CSP (helmet), including script-src-attr 'none'. There are no inline <script> blocks without a nonce and no inline event handler attributes anywhere in views/ or public/assets/; anything added there must follow the same rule or the browser will refuse to run it. Set PULSE_CSP_REPORT_ONLY=1 to switch the policy to report-only (violations are reported to /csp-report and logged) while debugging.

Overview

PULSE is a centralized workflow execution system designed to orchestrate operations across distributed infrastructure. It provides a powerful web-based interface with a vintage CRT terminal aesthetic for defining, managing, and executing workflows that can span multiple servers, require human interaction, and perform complex automation tasks at scale.

Key Features

  • 🎨 Retro Terminal Interface: Phosphor green CRT-style interface with scanlines, glow effects, and ASCII art
  • ⚡ Quick Command Execution: Instantly execute commands on any worker with built-in templates and command history
  • 📊 Real-Time Worker Monitoring: Live system metrics including CPU, memory, load average, and active tasks
  • 🔄 Interactive Workflow Management: Define and execute multi-step workflows with conditional logic and user prompts
  • 🌐 Distributed Execution: Run commands across multiple worker nodes simultaneously via WebSocket
  • 📈 Execution Tracking: Comprehensive logging with formatted output, re-run capabilities, and JSON export
  • 🔐 SSO Authentication: Seamless integration with Authelia for enterprise authentication
  • 🧹 Auto-Cleanup: Automatic removal of old executions with configurable retention policies
  • 🔔 Terminal Notifications: Audio beeps and visual toasts for command completion events

Architecture

PULSE consists of two core components:

PULSE Server

Location: 10.10.10.65 (LXC Container ID: 122) Directory: /opt/pulse-server

The central orchestration hub that:

  • Hosts the retro terminal web interface
  • Manages workflow definitions and execution state
  • Coordinates task distribution to worker nodes via WebSocket
  • Handles user interactions through Authelia SSO
  • Provides real-time status updates and logging
  • Stores all data in MariaDB database

Technology Stack:

  • Node.js 22.x
  • Express.js (web framework)
  • WebSocket (ws package) for real-time bidirectional communication
  • MySQL2 (MariaDB driver)
  • Authelia SSO integration

PULSE Worker

Example: 10.10.10.151 (LXC Container ID: 153, hostname: pulse-worker-01) Directory: /opt/pulse-worker

Lightweight execution agents that:

  • Connect to PULSE server via WebSocket with heartbeat monitoring
  • Execute shell commands and report results in real-time
  • Provide system metrics (CPU, memory, load, uptime)
  • Support concurrent task execution with configurable limits
  • Automatically reconnect on connection loss

Technology Stack:

  • Node.js 22.x
  • WebSocket client
  • Child process execution
  • System metrics collection
┌─────────────────────────────────┐
│   PULSE Server (10.10.10.65)   │
│   Terminal Web Interface + API  │
│   ┌───────────┐ ┌──────────┐   │
│   │ MariaDB   │ │ Authelia │   │
│   │ Database  │ │   SSO    │   │
│   └───────────┘ └──────────┘   │
└────────────┬────────────────────┘
             │ WebSocket
    ┌────────┴────────┬───────────┐
    │                 │           │
┌───▼────────┐   ┌───▼────┐  ┌──▼─────┐
│ Worker 1   │   │Worker 2│  │Worker N│
│10.10.10.151│   │  ...   │  │  ...   │
└────────────┘   └────────┘  └────────┘
 LXC Containers in Proxmox with Ceph

Installation

Prerequisites

  • Node.js 22.x or higher
  • MariaDB 10.x or higher
  • Authelia configured for SSO (optional but recommended)
  • Network Connectivity between server and workers

PULSE Server Setup

cd /opt
git clone https://code.lotusguild.org/LotusGuild/pulse.git pulse-server
cd pulse-server
npm ci --omit=dev

cp .env.example .env      # then fill in the values (see Configuration below)
chmod 600 .env

cat > /etc/systemd/system/pulse.service << EOF
[Unit]
Description=PULSE Workflow Orchestration Server
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/opt/pulse-server
ExecStart=/usr/bin/node server.js
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable --now pulse.service
curl -s http://127.0.0.1:8080/healthz      # {"status":"ok", ..., "db":true}

The server creates its tables on first start. In production the unit file comes from jared/pve-infra and code updates arrive through CI (see "Deploys").

PULSE Worker Setup

A worker needs only worker/worker.js and the npm manifests from the repo root (its dependencies are axios, ws and dotenv, which the root lockfile pins):

mkdir -p /opt/pulse-worker && cd /opt/pulse-worker
# from a checkout of this repo:
cp <repo>/worker/worker.js <repo>/package.json <repo>/package-lock.json .
npm ci --omit=dev

cp <repo>/worker/.env.example .env   # set WORKER_NAME, PULSE_SERVER, PULSE_WS, WORKER_API_KEY
chmod 600 .env

cat > /etc/systemd/system/pulse-worker.service << EOF
[Unit]
Description=PULSE Worker Agent
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/opt/pulse-worker
ExecStart=/usr/bin/node worker.js
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable --now pulse-worker.service

The worker appears on the Workers tab within a few seconds. Commands run as the service user (root here). After the first install, updates are automatic: see "Worker deploys" for the hook that lets CI install each new commit on the worker.

Usage

Quick Command Execution

  1. Access PULSE at http://your-server:8080
  2. Navigate to ⚡ Quick Command tab
  3. Select a worker from the dropdown
  4. Use Templates for pre-built commands or History for recent commands
  5. Enter your command and click Execute
  6. View results in the Executions tab

Built-in Command Templates:

  • System Info: uname -a
  • Disk Usage: df -h
  • Memory Usage: free -h
  • CPU Info: lscpu
  • Running Processes: ps aux --sort=-%mem | head -20
  • Network Interfaces: ip addr show
  • Docker Containers: docker ps -a
  • System Logs: tail -n 50 /var/log/syslog

Worker Monitoring

The Workers tab displays real-time metrics for each worker:

  • System information (OS, architecture, CPU cores)
  • Memory usage (used/total with percentage)
  • Load averages (1m, 5m, 15m)
  • System uptime
  • Active tasks vs. maximum concurrent capacity

Execution Management

  • View Details: Click any execution to see formatted logs with timestamps, status, and output
  • Re-run Command: Click "Re-run" button in execution details to repeat a command
  • Download Logs: Export execution data as JSON for auditing
  • Clear Completed: Bulk delete finished executions
  • Auto-Cleanup: Executions older than 30 days are automatically removed

Workflows

A workflow is a JSON definition with a list of steps, created on the Workflows tab (admin only) and started with Execute. Steps run in order unless one jumps elsewhere.

{
  "params": [
    { "name": "host", "label": "Host", "required": true },
    { "name": "service", "type": "select", "options": ["nginx", "myservice"], "default": "myservice" }
  ],
  "steps": [
    { "id": "probe", "type": "execute", "command": "ping -c 1 {{host}} >/dev/null && echo UP=yes || echo UP=no", "targets": ["node-01"] },
    { "id": "read", "type": "parse" },
    { "id": "decide", "type": "route", "conditions": [
      { "if": "state.up === 'yes'", "goto": "end", "label": "reachable" },
      { "default": true, "goto": "ask" }
    ] },
    { "id": "ask", "type": "prompt", "message": "{{host}} is down. Restart its service?", "options": ["Restart", "Skip"], "routes": { "Skip": "end" } },
    { "id": "restart", "type": "execute", "command": "systemctl restart {{service}}", "targets": ["node-01"], "retries": 2 }
  ]
}
Step type Fields What it does
execute command, targets (["all"] or worker names/ids; default all), condition, timeout (seconds, 5 to 600), retries (0 to 5), retryDelayMs, parallel (default true) Runs the command on all targets at once (parallel: false: one after another, stopping at the first failure); a failure on any target fails the workflow
parse condition Reads KEY=VALUE lines (key in capitals) from the last command's output into state.key (lower case)
route conditions: [{ "if", "goto", "label" }, { "default": true, "goto" }] Jumps to the first matching condition's step
prompt message, options, key, routes ({ "<option>": "<step id>" }) Waits for someone to answer in the UI (up to 60 min, never past the execution's time limit). An unanswered prompt fails the workflow
wait duration (seconds) Pauses, never past the execution's time limit

Any step can have goto: "<step id>" or goto: "end". Saving a workflow checks its shape and refuses it with the reasons: each step's type and required fields (an execute needs a command, a prompt needs message and options, a route needs conditions), unique ids, every goto naming an existing step, conditions that parse, and the params definitions.

Conditions (condition, route if) are expressions over state.* (values from parse and prompt answers), params.* and promptResponse: comparisons (=== !== < > <= >=), && || !, arithmetic, parseInt, parseFloat, Number, String, Boolean, and the string methods trim, toLowerCase, toUpperCase, includes, startsWith, endsWith. They are evaluated by a small interpreter (lib/condition.js), never as JavaScript, and a condition that doesn't parse is rejected when the workflow is saved.

Parameters (params) are asked for in the Run dialog and substituted into commands as {{name}}. Each has a name, and optionally label, required, default, placeholder and a type:

type Field Value
text (default) text box letters, digits and . _ : @ / - only
number number box; min, max a number in range
select dropdown of options one of the options
boolean checkbox true or false
worker dropdown of connected workers a worker's name

Values are checked when the run is requested, both in the dialog and by the server (which answers 400 with the reasons), so a bad value never starts a run. Defaults fill in anything left empty.

Dry run logs each command without running it. Abort stops the workflow before its next step and kills its running commands on the workers. A workflow can have a webhook_url: Pulse POSTs {execution_id, workflow_id, workflow_name, status, started_by, started_at, completed_at} to it when the execution completes or fails. The whole execution is limited to EXECUTION_MAX_MINUTES (default 60).

Scheduler

The Scheduler tab (admin only) runs a command on chosen workers on a schedule: interval (every N minutes), hourly (every N hours), daily (HH:MM) or cron (a cron expression). Each run is an execution started by scheduler:<name>. A run whose worker is offline is recorded as failed ("Worker offline"), and a schedule whose previous run is still going is skipped.

While you set a schedule, the dialog previews its next three runs. daily times and cron expressions are worked out in the server's time zone, which the preview names. Edit changes a schedule in place and works out its next run again. Run now runs it at once (recording who asked) without moving its next run. Runs opens its past executions.

Features in Detail

Terminal Aesthetic

  • Phosphor green (#00ff41) on black (#0a0a0a) color scheme
  • CRT scanline animation effect
  • Text glow and shadow effects
  • ASCII box-drawing characters for borders
  • Boot sequence animation on first load
  • Hover effects with smooth transitions

Real-Time Communication

  • WebSocket-based bidirectional communication
  • Instant command result notifications
  • Live worker status updates
  • Terminal beep sounds for events
  • Toast notifications with visual feedback

Execution Tracking

  • Formatted log display (not raw JSON)
  • Color-coded success/failure indicators
  • Timestamp and duration for each step
  • Scrollable output with syntax highlighting
  • Persistent history with pagination
  • Load More button for large execution lists

Security

  • Authelia SSO integration for user authentication, with identity headers only accepted from TRUSTED_PROXIES
  • API key authentication for workers
  • User session management
  • Admin-only: Pulse admits only the Authelia admin group
  • Audit logging for all executions

Performance

  • Automatic cleanup of old executions (configurable retention)
  • Pagination for large execution lists (50 at a time)
  • Efficient WebSocket connection pooling
  • Worker heartbeat monitoring
  • Database connection pooling

Configuration

Environment Variables

Server (.env): .env.example lists them all.

Variable Default Purpose
PORT, HOST 8080, 0.0.0.0 Where the server listens
DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD (required) MariaDB connection
TRUSTED_PROXIES (required) Proxies allowed to send Authelia identity headers (see below)
WORKER_API_KEY (required) Shared key workers authenticate with
WORKER_AUTH_ENFORCE off 1 refuses workers that don't send the key (see below)
GANDALF_API_KEY (none) Key for Gandalf's /api/internal/* calls; unset disables them
EXECUTION_MAX_MINUTES 60 Time limit for a workflow execution
EXECUTION_RETENTION_DAYS 30 Executions older than this are deleted
PULSE_API_RATE_MAX, PULSE_EXEC_RATE_MAX 1000 per 15 min, 20 per min Rate limits per signed-in user (and for Gandalf)
APP_NAME, APP_SUBTITLE PULSE, Worker Orchestration // LotusGuild Branding
PULSE_CSP_REPORT_ONLY off 1 reports CSP violations instead of enforcing
PULSE_DEV_READONLY (alias DISABLE_BACKGROUND_JOBS) off Local dev guard: no background writes (see below)
NODE_ENV production in production

Test stacks only (scripts/ci/ui-stack.sh sets them): PULSE_SCHEDULER_TICK_MS, PULSE_PROMPT_TIMEOUT_MS.

Worker (.env): worker/.env.example.

Variable Default Purpose
WORKER_NAME hostname Name shown in Pulse; must be unique
PULSE_SERVER, PULSE_WS http://localhost:8080, ws://localhost:8080 Server URLs
WORKER_API_KEY (required) Same value as the server's
HEARTBEAT_INTERVAL 30 Seconds between heartbeats
MAX_CONCURRENT_TASKS 5 Commands run at once; more are refused with an error

Trusted proxies

Authelia's forward auth passes the user to Pulse in the Remote-User, Remote-Name, Remote-Email and Remote-Groups headers. Those headers are only trustworthy when the reverse proxy sent the request, because the proxy overwrites them. Pulse listens on every interface, so any other host that can reach the port could set them itself and log in as anyone.

TRUSTED_PROXIES is a comma-separated list of addresses or CIDR ranges (IPv4 or IPv6). Pulse only accepts identity headers from a connection whose peer address is on the list. It uses the TCP peer, not X-Forwarded-For or X-Real-IP, which a client could forge. Requests from anywhere else are treated as not logged in, and are logged with their source address. It fails closed: if TRUSTED_PROXIES is unset, no SSO login succeeds and a warning is printed at startup. Invalid entries are logged and skipped. Worker and Gandalf API-key routes don't use it.

WebSocket authentication

Every WebSocket upgrade is authenticated. A browser connection must come through a trusted proxy (see above) with an Authelia identity in the admin group (Pulse is admin-only), and only those connections receive the live event feed. A worker authenticates with Authorization: Bearer <WORKER_API_KEY> at the handshake, and also sends the key in its worker_connect message. A wrong key is always refused. Only a connection that identified as a worker can deliver command results, and only for commands the server sent to that worker.

Workers older than this change don't send a key. Until every worker is updated, leave WORKER_AUTH_ENFORCE unset: keyless workers are still accepted, with a [Security] warning naming the worker, and an unauthenticated connection that doesn't identify as a worker within 30 s is closed. Once the warnings stop, set WORKER_AUTH_ENFORCE=1 and restart. From then on, upgrades with no valid credentials get a 401.

Local development against a real database

Running a local instance against the production MariaDB is safe only with the read-only guard on:

PULSE_DEV_READONLY=1 PORT=8099 HOST=127.0.0.1 npm start

PULSE_DEV_READONLY=1 (alias DISABLE_BACKGROUND_JOBS=1) disables every background writer, so a dev instance can never mutate shared state behind your back: stale-execution recovery at startup, the old-execution cleanup job (startup call and interval), the scheduled-command processor (startup call and interval), and the stale-worker offline sweep. Each skip is logged at startup alongside a PULSE_DEV_READONLY IS ON banner. The guard covers background jobs only: API routes still write, so avoid destructive actions in the UI when you are pointed at production data.

Worker (.env):

WORKER_NAME=pulse-worker-01         # Unique worker name
PULSE_SERVER=http://10.10.10.65:8080   # Server HTTP URL
PULSE_WS=ws://10.10.10.65:8080          # Server WebSocket URL
WORKER_API_KEY=<api-key>            # Must match server key
HEARTBEAT_INTERVAL=30               # Heartbeat seconds (default: 30)
MAX_CONCURRENT_TASKS=5              # Max parallel tasks (default: 5)

Database Schema

The server creates these tables in MariaDB on start:

Table Key columns
users username, display_name, email, groups, last_login: Authelia identities seen by Pulse
workers id, name, status (online/offline), last_heartbeat, metadata (JSON: system info, memory, load, version)
workflows id, name, description, definition (JSON), webhook_url, created_by
executions id, workflow_id (null for commands), status (running/completed/failed), started_by (a user, gandalf:... or scheduler:<name>), started_at, completed_at, logs (JSON list of steps, commands and results)
scheduled_commands id, name, command, worker_ids (JSON), schedule_type, schedule_value, enabled, last_run, next_run

Troubleshooting

Worker Not Connecting

# Check worker service status
systemctl status pulse-worker

# Check worker logs
journalctl -u pulse-worker -n 50 -f

# Verify API key matches server
grep WORKER_API_KEY /opt/pulse-worker/.env

Commands Stuck in "Running"

They shouldn't stay that way: a command fails when its worker disconnects, when no result arrives within its timeout, and a sweep every 5 minutes fails anything still running past EXECUTION_MAX_MINUTES (or left over from a server restart). If one does stay stuck, check journalctl -u pulse for the execution id.

Clear Completed Executions

Use Clear Completed on the Executions tab; old executions are also deleted after EXECUTION_RETENTION_DAYS.

License

MIT License - See LICENSE file for details


CI / CD

Everything runs from .gitea/workflows/ci.yml:

Job What it does When
Lint (eslint) npm run lint (errors on bugs-in-waiting such as ==, shadowed or unused variables and eval, plus eslint-plugin-security's recommended rules except object-injection; no warnings allowed), plus a check that fails on em or en dashes anywhere in the repo, including the vendored design system Every push and PR
Test (jest) npm test: unit tests for lib/ and the worker, and the deploy-script sandbox tests. Fails if coverage drops below the floors in package.json (lib/ 90% lines, worker/ 40%) Every push and PR
Security (npm audit) npm audit --audit-level=high, plus a CycloneDX SBOM of production dependencies (kept 90 days as the sbom-cyclonedx artifact of each main build) Every push and PR, and weekly (Monday 06:00)
Scan (secrets, workflows, shell) gitleaks over the whole git history, actionlint and zizmor on the workflow files (shellcheck on their scripts; zizmor for injection, credential persistence and unpinned images), shellcheck on every *.sh, a check that public/web_template is byte-identical to upstream at the commit in its VERSION, and semgrep (JavaScript, Node.js, Express, secrets and security-audit rule packs, plus Pulse's own rules in .semgrep/pulse.yml: no vm/eval, no shell commands in the server, no unescaped values in innerHTML; their test cases in .semgrep/pulse.js run first). Suppress a reviewed false positive on its line with nosemgrep: <rule id> and a comment saying why Every push and PR
Integration (api) Starts the real server and three workers on Node 22 against MariaDB, then runs tests/integration/ over HTTP and WebSocket: the Gandalf API contract, HTTP and WebSocket auth, and execution reliability (worker crash, capacity, abort) Every push and PR
UI (playwright) Starts the real server and three workers against a MariaDB service container, then runs the Playwright tests in tests/ui/ (desktop and phone) Every push and PR
UI screenshots (before/after) On PRs that touch public/, views/ or the render/nav code: runs the base branch and the PR side by side with the same seeded data and uploads a ui-screenshots artifact with one before/after image per page (desktop and phone). Pages that came out identical are listed in unchanged.txt. Not a required check; attach the relevant images to the PR for review Pull requests
Deploy Calls the pulse-deploy webhook on CT 122, waits until /healthz reports the tested commit, then tags it deploy-* Push to main, only after all six checks pass
Notify Matrix alert on any failure on main or in the weekly audit, and on every deploy As needed

Branch protection on main requires CI / Lint (eslint) (pull_request), CI / Test (jest) (pull_request), CI / Security (npm audit) (pull_request), CI / Scan (secrets, workflows, shell) (pull_request), CI / Integration (api) (pull_request) and CI / UI (playwright) (pull_request) (branches are only built through their pull request; pushes build main). Actions are pinned to commit SHAs, container images to digests, checkouts don't keep the token, and builds use npm ci. The plan for the rest of the pipeline is tracked in #45.

Integration tests

tests/integration/ tests the running server as a black box, the way Gandalf and the workers use it: Gandalf's submit-and-poll contract (/api/internal/command, /api/internal/executions/:id), SSO and worker-key auth on HTTP and on the WebSocket upgrade, forged results from a browser socket, and that executions always finish (a worker killed mid-command, a worker at capacity, an abort followed by a late result). Tests that need to kill or limit a worker start their own. The workflow engine (execute, parse, route, prompt, params, dry run, loop detection, abort) and the scheduler are covered too; the scheduler tests make a schedule due by setting next_run in the database, and the stack ticks the scheduler every second (PULSE_SCHEDULER_TICK_MS). Known bugs are written as test.failing with their issue number: when a fix lands, the test starts failing until the marker is removed.

DB_HOST=127.0.0.1 DB_PORT=3399 DB_USER=pulse DB_PASSWORD=... DB_NAME=pulse scripts/ci/ui-stack.sh start
npm run test:integration

Design system

public/web_template/ is vendored from LotusGuild/web_template; never edit it here (CI checks it is byte-identical to upstream). Change the design system upstream, then vendor it:

scripts/sync-web-template.sh <path-to-web_template-checkout>

UI tests

The Playwright tests drive the real UI end to end: every page loads with no page errors, console errors or failed requests; commands typed into Quick Command run on a worker and their output appears in Executions; workflows are created and run from the UI; live updates arrive over the WebSocket; pages without an SSO identity are refused; and every page fits a phone screen. Any UI fix should come with a test here.

Run them locally against a throwaway database (see "Local development against a real database" for one way to start MariaDB):

npx playwright install chromium        # once
DB_HOST=127.0.0.1 DB_PORT=3399 DB_USER=pulse DB_PASSWORD=... DB_NAME=pulse scripts/ci/ui-stack.sh start
npm run test:ui                        # add --ui or --headed to watch
scripts/ci/ui-stack.sh stop

On a CI failure, the playwright-report artifact has the HTML report, traces and screenshots.

Deploys

CI sends an HMAC-signed payload {"ref", "sha", "ts"} to the webhook on CT 122. The webhook runs deploy/pulse_deploy.sh <sha> <ts>, which:

  1. refuses requests signed more than 5 minutes ago, or not newer than the last accepted one (replays);
  2. refuses commits that aren't on main;
  3. checks out exactly that commit, runs npm ci --omit=dev and restarts pulse;
  4. waits for GET /healthz to report that commit with a working database, and otherwise rolls back to the previous commit.

It logs to /var/log/pulse-deploy.log. GET /healthz (unauthenticated) returns {status, version, sha, db, workers, worker_versions, uptime_s} with 200, or 503 when the database is unreachable. worker_versions lists the commit each connected worker reports.

Installing or updating the deploy script (on CT 122, as root). The webhook runs the installed copy, not the one in the checkout, so a bad commit can't replace the code that rolls it back:

install -m 755 /opt/pulse-server/deploy/pulse_deploy.sh /usr/local/bin/pulse_deploy.sh

The pulse-deploy hook in /etc/webhook/hooks.json passes the signed values as arguments:

"pass-arguments-to-command": [
  { "source": "payload", "name": "sha" },
  { "source": "payload", "name": "ts" }
]

Worker deploys

The only worker today is pulse-worker-01 (LXC CT 153 on monitor-01, 10.10.10.151), installed in /opt/pulse-worker (worker.js, the npm manifests, node_modules, and its own .env), run by pulse-worker.service. The unit file itself is deployed from jared/pve-infra.

After the server deploys, the Deploy worker job checks the commit the connected workers report (worker_versions in /healthz). Only if worker/ or package-lock.json (any dependency change) changed since then does it call the HMAC-signed pulse-worker-deploy hook on CT 153, so unrelated merges don't restart the worker mid-command. The hook runs deploy/pulse_worker_deploy.sh <sha> <ts>, which:

  1. refuses stale or replayed requests, and commits that aren't on main;
  2. reads worker/worker.js, package.json and package-lock.json at exactly that commit from a local clone of the repo, installs them, writes the sha to VERSION, runs npm ci --omit=dev and restarts the worker (.env is never touched);
  3. waits until /healthz lists that sha among the connected workers, and otherwise restores the previous files.

CI then waits for the same thing before the job passes. The script logs to /var/log/pulse-worker-deploy.log.

Installing it on a worker host (as root; CT 153 already runs webhook):

install -m 755 pulse_worker_deploy.sh /usr/local/bin/pulse_worker_deploy.sh   # from deploy/ in this repo

and add a hook to /etc/webhook/hooks.json, with the same secret as the repo's WORKER_WEBHOOK_SECRET Actions secret:

{
  "id": "pulse-worker-deploy",
  "execute-command": "/usr/local/bin/pulse_worker_deploy.sh",
  "pass-arguments-to-command": [
    { "source": "payload", "name": "sha" },
    { "source": "payload", "name": "ts" }
  ],
  "trigger-rule": {
    "and": [
      { "match": { "type": "payload-hmac-sha256", "secret": "<WORKER_WEBHOOK_SECRET>",
                   "parameter": { "source": "header", "name": "X-Gitea-Signature" } } },
      { "match": { "type": "ip-whitelist", "ip-range": "10.10.10.70/32" } }
    ]
  }
}

Both Pulse hooks (pulse-deploy on CT 122 and pulse-worker-deploy on CT 153) only accept requests from the CI runner, 10.10.10.70, as well as requiring the signature. If the runner's address changes, deploys fail in CI (the verify step times out) until the ip-range is updated on both hosts.

To add a worker host, install Node 22 and the worker as above, give it a .env with WORKER_NAME, PULSE_SERVER, PULSE_WS and WORKER_API_KEY, and add its hook (one hook URL per host in the Deploy worker job).

Production installs Node from NodeSource's node_22.x apt repository. On Debian 13, use NodeSource's current signing key (https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key, dearmored to /usr/share/keyrings/nodesource.gpg): copies from before January 2026 bind the key with SHA-1, which Debian 13 rejects, so apt-get update reports the repository as unsigned.


PULSE - Orchestrating your infrastructure, one heartbeat at a time. ⚡

Built with retro terminal aesthetics 🖥️ | Powered by WebSockets 🔌 | Secured by Authelia 🔐

S
Description
PULSE: Pipelined Unified Logic & Server Engine. Central orchestrator that runs commands and workflows across a fleet of nodes via workers, with a live web UI.
Readme MIT
10 MiB
1 Stars 3 Watchers 0 Forks
Languages
JavaScript 66.7%
CSS 25.7%
EJS 4.1%
Shell 1.9%
Python 1.6%