Skip to content

Documentation

Autonomous Maintenance

How the SveltyCMS System Watchdog performs proactive self-healing and performance optimization.

11/1/2026
3 min read Edit on GitHub

This page is the background watchdog: cache compaction, index checks, and the soft-delete lifecycle. Emails and webhooks that you configure are Automations.

SveltyCMS 2026 introduces Autonomous Maintenance, a background self-healing layer that proactively optimizes the system without human intervention. This is orchestrated by the System Watchdog.


🐕 The System Watchdog

The Watchdog is a persistent background service initialized during the WARMING phase. It executes a health check loop every 5 minutes.

Core Responsibilities

  1. Service Re-initialization: If a critical adapter (e.g., Database or Auth) reports a FAILED state, the Watchdog attempts a surgical reinitializeSystem() call.
  2. Resource Monitoring: Tracks RAM and CPU spikes, logging anomalies to the Enterprise Monitor.
  3. Drift Detection: Verifies that the database schema remains in sync with the filesystem-based “Source of Truth.”

⚡ Cache Compaction

To prevent memory bloat in high-traffic environments, the Watchdog monitors the internal L1 Cache (in-memory store).

  • Threshold: Compaction is triggered when the cache exceeds 10,000 items or a 30% fragmentation level.
  • Action: The system performs a “LRU Sweep,” purging the least-recently-used items across all tenants while preserving “Hot” system settings and auth sessions.
  • Result: Ensures the SvelteKit server maintains a stable memory footprint, even during massive content imports.

🗄️ Database Index Optimization

The Watchdog analyzes query performance bubbled up through the DatabaseResilience micro-telemetry.

  • Slow Query Detection: If queries consistently exceed 50ms, the Watchdog logs a performance incident.
  • Auto-Indexing: For MongoDB and SQL adapters, the system can autonomously rebuild missing indexes for fields marked as searchable or unique in the collection schema if it detects a full table scan is occurring.

🗑️ Trash Lifecycle

SveltyCMS uses “Soft Deletes”: a delete sets isDeleted and keeps the row.

  • What a soft delete writes: isDeleted: true, updatedAt, and — on both the SQL and Mongo paths — deletedAt plus deletedBy (the acting user). SQL writes the audit pair only when the physical column exists, so older system tables keep working.
  • Trash list: /config/trash and GET /api/trash list soft-deleted rows per collection. The title falls back through title (plain, locale map, or the JSON data blob) → name → the first display string → _id, so a row without a title field is still identifiable. Timestamps fall back to updatedAt / updatedBy for rows trashed before deletedAt / deletedBy existed.
  • Restore: POST /api/trash/restore (with { collectionId, entryId }) reverses the soft delete and restores the mangled unique fields.
Important

No automatic purge is shipped. Nothing deletes trashed rows on a timer, and there is no user-facing “empty trash” API — an operator removes a row permanently through the collection. (The E2E harness has a purge-trash action on the fail-closed /api/testing backdoor; it is not a product feature.) There is therefore no 30-day retention job to configure. Earlier revisions of this page described one that does not exist.


📊 Monitoring

Admins can track maintenance activity in the Enterprise Monitor (/config/monitor), which shows the security incident feed, service health, webhook status, the audit trail, and system vitals.

  • Uptime: metricsService.getSystemMetrics().uptime is milliseconds and is rendered by formatUptimeMs() (29m, 1d 2h 3m, < 1m, Just started). There is no magnitude heuristic.
  • Service health: per-service status, message, last check, initialisation duration, and failure count from the system state machine.
  • Cache metrics: hit rate, operations, and per-category breakdown.

📚 Related Documentation


Related

maintenancewatchdogperformanceself-healing
Was this page helpful?