Skip to content

Documentation

Autonomous Maintenance

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

4/11/2026
2 min read Edit on GitHub

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.

πŸ—‘οΈ Automated Trash Purge

While SveltyCMS uses β€œSoft Deletes” by default, the maintenance layer manages the archival lifecycle.

  • Retention Policy: By default, items in the Trash are kept for 30 days.
  • Autonomous Purge: During the nightly maintenance window, the Watchdog permanently removes items that have exceeded the retention threshold, reclaiming database storage.

πŸ“Š Monitoring

Admins can track autonomous activity in the Enterprise Monitor under the System Vitals quadrant.

  • Last Run: Timestamp of the most recent maintenance cycle.
  • Heals Performed: Count of automated service recoveries.
  • Purge Stats: Number of items cleared from trash/cache.

πŸ“š Related Documentation


Related

maintenancewatchdogperformanceself-healing
Was this page helpful?