Autonomous Maintenance
How the SveltyCMS System Watchdog performs proactive self-healing and performance optimization.
On this page
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
- Service Re-initialization: If a critical adapter (e.g., Database or Auth) reports a
FAILEDstate, the Watchdog attempts a surgicalreinitializeSystem()call. - Resource Monitoring: Tracks RAM and CPU spikes, logging anomalies to the Enterprise Monitor.
- 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
searchableoruniquein 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 —deletedAtplusdeletedBy(the acting user). SQL writes the audit pair only when the physical column exists, so older system tables keep working. - Trash list:
/config/trashandGET /api/trashlist soft-deleted rows per collection. The title falls back throughtitle(plain, locale map, or the JSONdatablob) →name→ the first display string →_id, so a row without atitlefield is still identifiable. Timestamps fall back toupdatedAt/updatedByfor rows trashed beforedeletedAt/deletedByexisted. - Restore:
POST /api/trash/restore(with{ collectionId, entryId }) reverses the soft delete and restores the mangled unique fields.
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().uptimeis milliseconds and is rendered byformatUptimeMs()(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.