Getting Started

Tutorial: Building with CleaveDB

Conditional Bonds

In complex security, access control, and dynamic workflow systems, a relationship should only be navigable when specific business conditions are satisfied. CleaveDB supports Conditional Bonds—graph edges that remain dormant until document attributes meet specified criteria.

Configuring a conditional edge

Append an IF condition after AS "<label>" inspecting properties on the target or source document:

CleaveQLExample · Conditional access bond
BOND "users:alice" TO "files:secret_doc" AS "can_read"
  IF clearance = "public"

As long as secret_doc has "clearance": "public", the bond is live. If the document is updated and clearance changes to "restricted", the edge immediately becomes dormant.

Checking target vs source attributes

You can inspect fields on either end of the relationship:

Condition SyntaxEvaluated Against
IF status = "active"Target document field (default)
ONLY WHEN status IS "active"Target document field (synonym)
IF source role IS "admin"Source document field
IF my role = "admin"Source document field
IF their role = "user"Target document field

Querying live vs dormant bonds

Standard graph traversal queries automatically filter out dormant bonds. To inspect dormant edges without activating them, use FIND CANDIDATE:

CleaveQLExample · Querying navigable vs candidate bonds
-- Normal traversal: returns active bonds only
FIND "can_read" OF "users:alice"

-- Candidate check: returns dormant bonds whose conditions are currently unmet
FIND CANDIDATE "can_read" OF "users:alice"