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
| Policy | Canonical syntax | Effect |
|---|---|---|
| Audit Trail | SHAPE BUCKET orders AUDITED | Logs every write to _audit_<bucket> |
| Versioning | SHAPE BUCKET orders VERSIONED | Retains full historical document snapshots on mutations |
| Capacity Cap | SHAPE BUCKET orders MAX DOCUMENTS 100 | Enforces a hard document quota ceiling |
| Compression | SHAPE BUCKET orders COMPRESSION zstd | Applies transparent block-level compression |
| TTL Expiry | SHAPE BUCKET orders TTL 3600 | Automatically 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>:
SHAPE BUCKET orders AUDITEDTo 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:
SHAPE BUCKET orders VERSIONEDWith 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:
-- Full multi-attribute statement:
SHAPE BUCKET orders VERSIONED AUDITED MAX DOCUMENTS 50
-- Short form omitting BUCKET keyword:
SHAPE orders AUDITED