Getting Started

Tutorial: Building with CleaveDB

HEAL — repair integrity

Over time, high-throughput systems experience orphaned references, corrupted secondary index entries, or dangling graph edges following hard deletes. The HEAL command performs automated consistency audits and cleans up broken pointers across the storage engine.

Repair variants

CleaveDB offers targeted repair scopes depending on the operational requirement:

VariantSyntaxRepair Effect
Bonds onlyHEAL BONDSRemoves bonds whose source or target document no longer exists in _bonds
Links onlyHEAL LINKSRemoves links whose source or target document no longer exists in _links
Secondary indexesHEAL INDEXESRebuilds secondary indexes from primary document data
Full system repairHEAL ALLHeals bonds, links, secondary indexes, and structural inconsistencies

Cleaning up ghost bonds (HEAL BONDS)

When a document is permanently purged from the recycling bin via INCINERATE, existing bonds pointing to that deleted document become orphaned ghost bonds. HEAL BONDS detects and prunes them automatically:

CleaveQLExample · Clean up orphaned relationships
-- Run after bulk incinerations or migrations
HEAL BONDS

This ensures graph traversals (FOLLOW and MATCH) never traverse into non-existent nodes.

Automating HEAL via cron

In production environments, you can schedule periodic self-healing using the built-in scheduler:

CleaveQLExample · Scheduled hourly repair
EVERY 1 HOUR DO ( HEAL ALL )

The background cron worker sweeps the database and guarantees graph consistency without manual database administrator intervention.