Getting Started

Tutorial: Building with CleaveDB

SHAPE — Configure Buckets

The SHAPE command configures persistence parameters, retention policies, and lifecycle behaviors for an entire bucket. In CleaveDB, repeated SHAPE invocations accumulate onto the bucket's saved policy without overwriting prior options.

Supported configuration options

PolicyCanonical syntaxEffect
Audit TrailSHAPE BUCKET orders AUDITEDLogs every write to _audit_<bucket>
VersioningSHAPE BUCKET orders VERSIONEDRetains full historical document snapshots on mutations
Capacity CapSHAPE BUCKET orders MAX DOCUMENTS 100Enforces a hard document quota ceiling
CompressionSHAPE BUCKET orders COMPRESSION zstdApplies transparent block-level compression
TTL ExpirySHAPE BUCKET orders TTL 3600Automatically purges records after TTL seconds

Audit logging with AUDITED

Enabling AUDITED automatically records every modification (POUR, CHANGE, DRAIN) into an immutable ledger named _audit_<bucket>:

CleaveQLExample · Enable audit trail
SHAPE BUCKET orders AUDITED

To prevent unauthorized tampering, audit buckets are system-protected: querying FIND _audit_orders requires developer credentials.

Document versioning

Preserve complete point-in-time snapshots of records as they change:

CleaveQLExample · Enable versioning
SHAPE BUCKET orders VERSIONED

With VERSIONED active, prior versions can be queried using historical time-travel commands (like AS OF and REWIND).

Combining multiple policies

You can configure multiple attributes in a single statement, or use the concise form without the BUCKET keyword:

CleaveQLExample · Multi-policy configuration
-- Full multi-attribute statement:
SHAPE BUCKET orders VERSIONED AUDITED MAX DOCUMENTS 50

-- Short form omitting BUCKET keyword:
SHAPE orders AUDITED