Core Concepts

Graph Relations

Unlike traditional SQL databases that rely on expensive mathematical JOIN operations across tables, CleaveDB natively treats document relationships as physical graph edges (Bonds). Bonds are not just static pointers; they are richly configurable objects with functional attributes, enabling high-performance, unlimited-depth traversals.

Graph Relations Overview

Creating Bonds (LINK)

The LINK command (aliased as BOND) is used to establish relationships between two distinct documents, even if they reside in completely different buckets. Every bond can be assigned a semantic string label.

CleaveQL
/* Standard Directed Bond */
LINK "users:jane" TO "users:juan" AS "friend"

/* Bidirectional (Mutual) Bond */
LINK "users:jane" AND "users:pedro" AS MUTUAL "co_worker"

/* Multi-Target Graphing */
LINK "users:jane" TO ANY("tag:sql", "tag:rust") AS "skill"

Bond Modifiers

ModifierSyntaxDescription
ExclusiveEXCLUSIVELYExpires/removes all prior active bonds with the same source and label.
CascadeON DELETE CASCADEIf the source document is drained, the target is automatically drained.
WeightsWITH CONFIDENCE 0.9Attaches probabilistic or affinity floating-point weights to the edge (0.0 - 1.0).
TTL ExpiryEXPIRING IN n HOURSCreates an ephemeral time-bound edge that is automatically severed by the Cron GC.

Conditional Bonds (Dormant Edges)

Bonds can be configured to only activate when specific JSON fields within the source or target documents meet certain criteria. If the condition fails, the bond becomes "dormant" (invisible to standard traversal). If the document is later updated (CHANGE) to satisfy the condition, the bond instantly reactivates.

CleaveQL
LINK "users:alice" TO "files:secret_doc" AS "can_read" 
  IF target clearance IS "public"

/* If the file clearance changes to "private", this query returns 0 results */
FIND "can_read" OF "users:alice"

Graph Traversal

Traversing the graph requires no complex syntax. You can walk a single hop, or trace N-hops deep conversationally.

CleaveQL
/* Single Hop Traversal */
FIND "friend" OF "users:alice"

/* Multi-Hop Deep Traversal (Reading right-to-left) */
FIND THE knows OF THE boss OF users "jane"

/* Explicit Multi-Hop Trace */
TRACE "manages", "mentors" FROM "users:ana"

Broad Neighborhood Exploration (FOLLOW)

Use the FOLLOW command to perform a Breadth-First Search (BFS) across the local neighborhood of a document, returning a flattened list of all reachable nodes.

FOLLOW "users:ana" THROUGH "manages" DIRECTION BOTH DEPTH 3 LIMIT 10

Pattern Matching Subgraphs

For advanced queries, CleaveDB supports structural subgraph pattern matching. Instead of chaining hops manually, you define the exact shape of the graph you are looking for across multiple buckets, and CleaveDB will resolve the entire subgraph at once.

CleaveQL
/* Who does Ana manage that also mentors someone? */
FIND PATTERN staff AS a LINKED VIA "manages" TO staff AS b LINKED VIA "mentors" TO staff AS c

/* Find which staff live in a specific geographic place bucket */
FIND PATTERN staff AS s LINKED VIA "lives_in" TO places AS p

Destroying Bonds (SEVER)

The SEVER command (aliased as UNLINK) is used to destroy graph edges between documents. You can remove a specific labeled edge, or sever all edges entirely.

CleaveQL
/* Remove a specific labeled bond */
SEVER "users:jane" FROM "users:juan" AS "friend"

/* Destroy ALL bonds between the two documents regardless of label */
SEVER "users:jane" FROM "users:juan"

Neuro-Symbolic Semantic Pathfinding

Graph databases traverse relationships symbolically, but they possess zero semantic understanding. Vector databases find conceptually similar data but are entirely flat. CleaveDB seamlessly merges Graph Edge Traversal with the ONNX Transformer.

At each hop of a BFS graph traversal, the Rust FFI engine computes the _mm512_dp_ps vector cosine similarity between the prompt's embedding and the adjacent nodes' embeddings. It dynamically prunes branches of the graph that do not match the semantic concept in a single CPU clock cycle, preventing BFS explosions and yielding highly intelligent, context-aware paths.

CleaveQL
FOLLOW "users:alice" THROUGH "friend" GUIDED BY MEANING "machine learning experts" THRESHOLD 0.75 DEPTH 6

Summary

CleaveDB transforms rigid relational JOINs into conversational graph traversal. By utilizing the LINK command, developers can map complex architectures with rich attributes like expiration TTLs and cascading deletes. Querying these relationships requires zero mathematical logic—you simply ask the database to walk the chain via FIND, explore the neighborhood with FOLLOW, or pattern-match massive subgraphs entirely in plain English. And with Neuro-Symbolic Semantic Pathfinding, the database intelligently prunes graph walks using real-time Transformer AI models.