Files
Pulse/ARCHITECTURE.md
pulse-triage[bot] 0d57e1de54 Align Architecture, Security, API, and Operations Help with runtime
Remove stale Claude OAuth and request-assisted MSP claims from
ARCHITECTURE.md and its in-app Help mirror so they match fail-closed
OAuth removal and self-serve provider-hosted MSP plans.

Align docs/security/TEMPERATURE_MONITORING.md with container SSH key
fallback warnings, source-IP authorized_keys restriction, and the
default-organization boundary for multi-tenant SSH collection.

Align docs/operations/ADAPTIVE_POLLING_ROLLOUT.md with current
dead-letter queue clearing on a later scheduled poll success while
preserving the older-build caveat.

Document landed security boundaries in SECURITY.md, docs/API.md, and
their in-app Help mirrors: header-only X-CSRF-Token checks, live-session
pulse_csrf issuance, atomic failed-login lockout across Basic-auth
configuration transfers, in-flight request-body credential revalidation,
admin session invalidation on quick-setup rotation, and cross-origin
base-URL credential re-entry for AI provider settings. Update the Patrol
weekly digest link in docs/API.md to point at AI.md for in-app Help and
add source-bound regression tests in scripts/tests/test_public_docs_claims.py.

Contract-Neutral: Documentation, Help mirrors, and doc regression tests aligned with existing runtime behaviour without changing code contracts.
Change-source: pulse-maintainer
2026-11-27 23:47:32 +00:00

16 KiB

Pulse Architecture

Pulse is a real-time infrastructure monitoring platform for Proxmox VE, Proxmox Backup Server, Proxmox Mail Gateway, Docker, machine agents, Kubernetes, TrueNAS, and early-access VMware vSphere environments. It uses a Go 1.26 backend and a SolidJS / TypeScript frontend.

🏗 High-Level Overview

The system runs as a single binary that serves both the API and the embedded frontend assets. It connects to infrastructure via platform-supported HTTP and WebSocket APIs and lightweight push-based agents, normalises everything into a Unified Resource model, and delivers real-time updates to clients over WebSocket.

flowchart TD
    User[Browser / Mobile] <-->|WebSocket + HTTP| Pulse[Pulse Server]
    Mobile[Mobile App] <-->|E2E Encrypted| Relay[Relay Server]
    Relay <-->|WebSocket| Pulse

    subgraph "Pulse Server (Go)"
        API[Decomposed API Router]
        WS[WebSocket Hub]
        Monitor[Reloadable Monitor]
        UR[Unified Resource Registry]
        AI[AI Subsystem]
        Config[Config Manager]
        License[Entitlements Engine]
        Audit[Audit Logger]
    end

    Pulse -->|HTTPS :8006| PVE[Proxmox VE]
    Pulse -->|HTTPS :8007| PBS[Proxmox Backup Server]
    Pulse -->|HTTPS| PMG[Proxmox Mail Gateway]
    Pulse -->|HTTPS| TrueNAS[TrueNAS SCALE/CORE]
    Pulse -->|HTTPS| vSphere[VMware vCenter]
    DockerAgent[Docker Agent] -->|HTTPS POST| API
    HostAgent[Host Agent] -->|HTTPS POST| API
    K8sAgent[Kubernetes Agent] -->|HTTPS POST| API

    Monitor --> UR
    UR --> WS
    UR --> API

🔌 Backend Architecture (Go)

All backend code lives under cmd/, internal/, and pkg/. The binary is assembled from cmd/pulse/main.go which delegates to pkg/server.Run().

Core Components

  1. Entry Point (cmd/pulse/main.go → pkg/server/server.go)

    • Loads unified configuration via internal/config.Load().
    • Initialises the RBAC manager (pkg/auth), audit logger (pkg/audit), and crypto layer (internal/crypto).
    • Creates a ReloadableMonitor that manages the lifecycle of all monitoring goroutines.
    • Starts the HTTP/HTTPS server, WebSocket hub, Patrol and AI services, and the Relay client for existing paired Pulse Mobile users (until 31 March 2027).
    • Supports graceful hot-reload via SIGHUP and .env file watching.
  2. Unified Resource Registry (internal/unifiedresources)

    • Central data model that normalises resources from Proxmox, PBS, PMG, Docker, machine agents, Kubernetes, TrueNAS, and VMware providers into a shared Resource contract.
    • Canonical v6 resource types: agent, vm, system-container, app-container, docker-host, k8s-cluster, k8s-node, pod, k8s-deployment, storage, pbs, pmg, ceph, physical_disk.
    • Identity-matching engine: merges resources across sources using machine IDs, DMI UUIDs, hostnames, IPs, and MAC addresses.
    • Provides typed views (NodeView, K8sClusterView, etc.) for consumer-specific queries.
    • Canonical API endpoint: GET /api/resources.
  3. Monitoring Engine (internal/monitoring)

    • Polymorphic monitors: Each Proxmox VE/PBS/PMG node runs in its own goroutine, polling via the platform REST API.
    • Agent receivers (internal/api): Unified host, Docker, and Kubernetes agents push metrics via HTTP POST to /api/agents/agent/report (with /api/agents/host/report as a legacy alias), /api/agents/docker/report, and /api/agents/kubernetes/report.
    • TrueNAS provider (internal/truenas): Uses the versioned JSON-RPC 2.0 WebSocket API on supported SCALE releases for system info, pools, datasets, disks, alerts, ZFS snapshots, and replication tasks. A version-gated REST path remains only for legacy SCALE and CORE systems.
    • Enterprise/internal multi-org aware: when PULSE_MULTI_TENANT_ENABLED=true, each organisation gets a separate shared-process monitor namespace with its own configuration.
  4. WebSocket Hub (internal/websocket)

    • Manages active browser connections with per-message compression (deflate).
    • Broadcasts state diffs to all subscribed clients; supports per-organization broadcasts for internal multi-org setups.
    • Enforces origin validation, organization-level authorization, and Enterprise/internal multi-org license gating.
  5. Decomposed API Router (internal/api)

    • The router is split into focused registration files for maintainability:
      • router_routes_auth_security.go: Auth, OIDC, SAML, SSO, security tokens, recovery, agent install scripts.
      • router_routes_monitoring.go: Unified resources, metrics history, charts, recovery points, alerts, notifications, discovery.
      • router_routes_ai_relay.go: AI settings, Patrol, Intelligence, mobile chat sessions, Relay config, and the approval workflow.
      • router_routes_licensing.go: Organisations, RBAC, audit logs, license/entitlements, reporting, and billing.
      • router_routes_registration.go: Config CRUD, agent reporting and registration, TrueNAS connections, update management, agent profiles, system settings.
      • router_routes_cloud.go: Hosted signup, magic links, and Stripe billing webhooks.
      • router_routes_debug.go: Admin-gated /debug/pprof routes when profiling is enabled.
    • Every endpoint enforces scoped access control (e.g., monitoring:read, settings:write, ai:execute, ai:chat).
  6. Relay Client (internal/relay)

    • Maintains a persistent WebSocket tunnel to a managed relay server for Pulse Mobile remote access (not the web UI).
    • Uses an ECDH key-exchange for per-channel end-to-end encryption.
    • Multiplexes multiple mobile sessions over a single connection with back-pressure (data limiter) and per-channel authentication.
    • Supports push notifications through the relay.
    • Gated by the relay license feature. Relay is no longer sold, and Pulse Mobile and Relay retire on 31 March 2027. Existing paired phones keep working until then, and continuing Relay subscribers receive Pro entitlements at their current price.
  7. AI Subsystem (internal/ai)

    • AI runtime (internal/ai/chat): The governed tool loop behind Patrol investigations and Pulse Mobile chat (the in-app chat window has been retired). Supports bring-your-own-key (BYOK) and local providers (OpenAI, Anthropic, Ollama, and other configured providers). Anthropic subscription OAuth is unsupported and fails closed. External agents reach the same tools through pulse-mcp.
    • Pulse Patrol: Scheduled background analysis that produces findings, predictions, and remediation plans. Autonomy levels: monitor, approval, assisted, full.
    • Intelligence Services: Patterns, correlations, anomalies, baselines, forecasts, and incident recording. All surfaced via /api/ai/intelligence/*.
    • Safety gates: Command execution disabled by default (--enable-commands opt-in). Circuit breakers and scoped permissions apply at every layer.
  8. Entitlements & Licensing (pkg/licensing)

    • Capability-key based gating: ai_autofix, rbac, multi_tenant, relay, agent_profiles, kubernetes_ai, ai_alerts, etc.
    • Core tiers include Community (free), Pro, a retiring legacy Relay tier (no longer sold, receiving Pro entitlements while active), a reserved hosted Cloud capability tier, provider-hosted MSP (self-serve 60-day evaluation and paid plans), and Enterprise/custom entitlements (including optional request-assisted Pulse-hosted MSP). The Cloud service is not generally available.
    • Activation, grant refresh, renewal, expiry, and legacy-license migration. Active state is exposed through /api/license/*.
  9. Provider-hosted MSP control plane (internal/cloudcp)

    • A Stripe-free provider control plane can run one isolated Pulse runtime/container per client workspace.
    • A signed MSP license sets the provider plan and client workspace cap.
    • Pulse Account handles the provider workspace roster, sign-in-once handoff, client-bound agent install paths, and provider access surfaces.
    • Each client runtime remains a normal Pulse instance for monitoring data, alerts, webhooks, reports, users, and audit history. Shared-process organizations are for Enterprise/internal multi-org, not the default MSP boundary.
  10. Recovery Engine (internal/recovery)

  • Aggregates backup data (PBS snapshots, ZFS snapshots, replication tasks) into a unified recovery point timeline.
  • Provides faceted queries: filter by type, source, status, and source health.
  • API: /api/recovery/points, /api/recovery/series, /api/recovery/facets, /api/recovery/rollups, /api/recovery/postures.
  1. Audit Logging (pkg/audit)
    • Defence-in-depth: every mutation is logged to SQLite, optionally signed with per-tenant encryption keys.
    • Async audit logging is on by default (PULSE_AUDIT_ASYNC=false disables it); see docs/CONFIGURATION.md.
    • Tenant-aware logger manager for isolated per-org audit trails.

Data Flow

  1. Collection:
    • Proxmox VE / PBS / PMG: Monitoring engine polls platform REST APIs (configurable intervals, defaulting to 10 s for PVE and 60 s for PBS and PMG).
    • Docker / Host / Kubernetes: Lightweight agents push metrics via HTTP POST on their configured interval.
    • TrueNAS: Provider polls the versioned JSON-RPC WebSocket API on supported SCALE releases, with REST compatibility limited to recognized legacy SCALE and CORE systems.
  2. Normalisation: Platform-specific responses are mapped into unifiedresources.Resource structs by adapters in internal/unifiedresources/adapters.go.
  3. Registration: Resources are inserted into the in-memory registry, which handles deduplication, identity matching, and status computation.
  4. Broadcast: The latest state snapshot is serialised to JSON and pushed to all connected WebSocket clients by the Hub.
  5. Persistence: Metrics history is stored in a SQLite-backed metrics store (pkg/metrics) with configurable retention.

🎨 Frontend Architecture (SolidJS)

The frontend is a modern SPA in frontend-modern/, built with SolidJS and TypeScript. It uses fine-grained reactivity (no Virtual DOM) for maximum performance.

Key Technologies

  • SolidJS: Reactive UI framework.
  • TailwindCSS with a semantic design token layer: All structural colours use CSS custom-property tokens (bg-base, bg-surface, text-base-content, border-border, etc.) defined in index.css— components never hardcode hex values. Light/dark mode switches automatically via class-based theme resolution.
  • Vite: Build tooling (dev server + production bundling).
  • Lucide Icons: Icon library (imported as solid components).

Routing & Navigation

Navigation is organised around platform-shaped pages with cross-platform operational surfaces:

Route Page Purpose
/ and /infrastructure Runtime home Monitor-first authenticated entry point
/proxmox/* Proxmox PVE, PBS, PMG, guests, storage, recovery, and Ceph
/docker/* Docker Hosts, containers, Compose projects, Swarm, images, and storage
/kubernetes/* Kubernetes Clusters, workloads, networking, storage, and events
/truenas/* TrueNAS Systems, pools, datasets, disks, apps, VMs, and recovery
/vmware/* vSphere Early-access vCenter, host, cluster, VM, datastore, and network views
/standalone/* Machines Agent-backed machines and host telemetry
/availability/* Availability Website, service, device, and TLS certificate checks
/alerts/* Alerts Alert rules, active alerts, history
/actions/* Actions Governed action proposals, approvals, delivery, and audit state
/patrol/* Patrol Attention queue, findings, investigations, and run history
/settings/* Settings Infrastructure, security, notifications, plans, and Intelligence

The retired aggregate /workloads, /storage, and /recovery top-level routes are not canonical navigation. Shared resource, storage, and recovery contracts remain backend building blocks consumed inside platform pages.

State Management

  • WebSocket store (stores/websocket.ts): Manages the live connection, reactive State object, reconnection logic, and per-org switching.
  • Session and capability stores (stores/sessionCapabilities.ts, stores/actionInbox.ts): Track signed-in capabilities and pending action inbox state.
  • AI stores (stores/aiAvailability.ts, stores/aiIntelligence.ts, stores/patrolAttention.ts): Hold whether AI is enabled for the session, Patrol findings, and the Patrol attention queue.
  • License store (stores/license.ts): Tracks plan tier, feature flags, and multi-tenant state.
  • System settings store (stores/systemSettings.ts): Caches server-side preferences (for example theme and feature toggles).

Component Design

  • Shared primitives in components/shared/: Card, Button, Toggle, FilterButtonGroup, Table — all mapped to the semantic design tokens.
  • Lazy-loaded pages: All top-level pages are loaded via lazy() with optional preloading after initial render.
  • Virtual table windowing: Large resource lists use virtualised rendering for smooth scrolling at scale.
  • Command Palette (Cmd/Ctrl+K): Quick-access command launcher.
  • Keyboard shortcuts: g s → Machines, g c → Availability, g p → Proxmox, g d → Docker, g k → Kubernetes, g n → TrueNAS, g v → vSphere, g a → Alerts, g r → Patrol, g t → Settings, / → Search, ? → Keyboard shortcuts.

Mobile Experience

  • MobileNavBar component: Bottom tab bar for touch navigation in the mobile web UI.
  • Relay integration: Connects existing paired Pulse Mobile apps through the encrypted relay protocol until Pulse Mobile and Relay retire on 31 March 2027. For mobile access afterwards, use Pulse in your phone's browser and configure ntfy, Gotify, or Pushover alerts.

🔒 Security

  • Encryption at Rest: Sensitive config (passwords, API keys) encrypted with AES-GCM via internal/crypto. Each tenant can have its own encryption key.
  • Scoped API Tokens: Tokens carry explicit scopes (monitoring:read, settings:write, ai:chat, ai:execute, docker:report, etc.). Endpoints enforce scope checks before processing.
  • RBAC: Role-based access control via pkg/auth with SQLite-backed persistence. Standard resources: settings, audit_logs, nodes, users, license, ai, discovery, actions, and alerts.
  • SSO: OIDC and SAML providers with per-provider configuration and multi-provider support.
  • Agent Commands: Disabled by default for security. Operators must opt in with --enable-commands.
  • Audit Trail: Every mutation logged to per-tenant SQLite databases with optional cryptographic signatures.
  • Rate Limiting: Per-endpoint and per-tenant rate limiting with configurable thresholds.
  • CSRF Protection: Token-based CSRF prevention on mutation endpoints.
  • Recovery Mode: Localhost-only endpoint for emergency auth recovery with time-limited tokens.

🚀 Deployment

Pulse is distributed as:

  1. Docker Container: Multi-stage build producing a minimal image with the Go binary + embedded frontend.
  2. Single Binary: The frontend is compiled into the Go binary using go:embed (internal/api/frontend_embed.go), enabling single-file deployment.
  3. Kubernetes Helm Chart: For cluster deployments with configurable replicas and persistence.
  4. Systemd Service: For bare-metal or VM installations with .env-based configuration and SIGHUP reload support.
  5. Proxmox LXC Helper Script: One-line install inside a Proxmox helper-scripts container.