Getting Started

Tutorial: Building with CleaveDB

Scheduled Tasks & Triggers — Overview

Traditional database stacks require an assortment of external tooling—such as system cron daemons, Celery queues, Airflow workflows, and Kafka/Debezium CDC pipelines—just to handle periodic cleanup, aggregated reports, and event propagation. CleaveDB eliminates this architectural sprawl with native, kernel-level automation.

The Three Pillars of Automation

1. Repeating Tasks (EVERY)

Schedule recurring queries (interval cleanups, nightly health checks, periodic distill rollups) using human-readable cron expressions like EVERY 5 MINUTES DO (...).

2. Database Triggers (ON ... RUN)

Execute reactive CleaveQL operations when documents are inserted or modified, with dynamic key interpolation ($gid, $amount).

3. Webhooks for CDC

Publish real-time Change Data Capture payloads to external HTTP endpoints on writes, updates, and deletes without configuring message queues.

Execution Safety & Isolation

Every automated routine in CleaveDB is subject to the database engine's safety guarantees:

  • Recursion Depth Protection: Triggers maintain an execution context counter (trigger_depth) capped at 5. Any circular trigger relationship is halted before causing stack overflow panics.
  • Transactional Atomicity: When triggered within an active BEGIN ... COMMIT block, trigger errors immediately roll back uncommitted parent mutations.
  • Audit Attribution: Scheduled tasks execute with authenticated session context and append execution records into the system audit log.

Explore the Automation Topics

Follow the sections below to configure automated routines in CleaveDB: