Pre-release · community install coming soon

Semantic SQL,
native to DuckDB.

Decisions, lazy decision trees, embeddings and MCP as ordinary expressions in DuckDB 2.0+. One extension. One OpenRouter key. No gateway.

$ git clone --recurse-submodules https://github.com/ryrobes/rvbbitduck.git
  • DuckDB 2.0+
  • C++ extension
  • MIT
  • Bundled libcurl, no httpfs
quickstart.sql
LOAD rvbbit;

CREATE SECRET rvbbit (TYPE openrouter, KEY 'sk-or-...');
-- or export OPENROUTER_API_KEY=sk-or-...

SELECT id
FROM tickets
WHERE rvbbit.truth(body, 'The customer explicitly asks to cancel');

SELECT rvbbit.choose(body,
  ['billing', 'technical problem', 'cancellation', 'other'])
FROM tickets;
1OpenRouter key
0gateways to run
2.0+DuckDB, 2.0.1 pinned
MITlicensed, Ryan Robitaille

What you get

The rvbbit decision core, rebuilt for DuckDB.

A port of the decision core and the main text operators from rvbbit 1.2.3, Ryan's Postgres extension. The Postgres parser could not host real words like MEANS or a CREATE DECISION TREE statement. DuckDB 2.0 can, and a vector of up to 2048 rows is already a batch.

Decisions as expressions

truth, truth_score, choose and decide are ordinary SQL expressions. Use them in WHERE, JOIN and GROUP BY. A vector of up to 2048 rows is already a batch.

truthchoosedecide

Lazy decision trees

A tree is validated before any call, and only the path taken is judged. Every run returns a status, a label and the path it walked.

branchsave_treerun_tree

A catalog of text operators

Seeded from Calliope 1.2.3: means, about, summarize, classify, extract, sentiment, redact, headline and more. Define your own with create_operator.

summarizeclassifyextract

Embeddings and NEAREST

embed returns a FLOAT[] that works with DuckDB NEAREST and array_cosine_similarity. When vss is loaded, embed_index builds a cosine HNSW index.

embednearest_labelknn_text

Semantic aggregates

classify_collection, summarize_collection, consensus and collection_themes are real GROUP BY aggregates, not per-row calls in disguise.

GROUP BYconsensusthemes

Vision and ranking

image_part packs PNG or JPEG bytes. locate returns top, bottom, left, right and confidence. truth_rank picks the best level from a list you supply.

locateimage_parttruth_rank

A ledger for every call

Each OpenRouter call and each cache hit becomes a row: model, tokens, cost, latency, status. The total in spend() is the exact sum. Your key is never stored.

ledger()spend()

Local and alternate providers

Point chat and embeddings at a vLLM or llama.cpp server with an rvbbit_provider secret, or name a raw http://host:port/model address. OpenRouter stays the default.

vLLMllama.cppgpu:model

MCP, from SQL

Attach any MCP server over HTTP or stdio. Call tools, read rows, wrap them as macros, or use FROM MCP. Mutations are guarded and never cached.

mcp_callmcp_rowsmcp_wrap

In practice

Judgment that composes like SQL.

The function form is the source of truth. The grammar is sugar that desugars to the same functions, so nothing about the API changes when you turn it on.

Decisions you can put in a WHERE clause

truth is a boolean. truth_score is the number behind it. choosepicks a label. Decisions are answered by Jev through OpenRouter's decisions endpoint.

  • Identical bodies in a vector are deduped and posted together.
  • Questions about the same state share one request, up to 8, when fused.
  • NULL inputs skip the call.
SELECT rvbbit.truth_score(body, 'The customer explicitly asks to cancel') AS score
FROM tickets;

SELECT rvbbit.choose(body, ['billing', 'technical problem', 'cancellation', 'other'])
FROM tickets;
SELECT rvbbit.semantic_case(
  body,
  ['The customer explicitly asks to cancel', 'The request is about billing'],
  ['retention', 'finance'],
  [0.8, 0.5],
  'triage')
FROM tickets;

Trees that only judge the path taken

Constructors are pure. A tree is validated before any call, and an unreachable leaf is never judged. Prior judgments travel down the path as interpretations, not new evidence. The result is a struct with label, status, path and friends.

completeunavailablebudget_exhaustedcontext_limitmissing_input

Save one with save_tree, run it by name with run_tree. Rows in a vector are scheduled in waves, so a normal SELECT already batches.

yesnoyesnoMeaningful churn risk?Unresolved service problemis the main concern? · threshold 0.7routine follow-upnever judgedrelationship reviewservice intervention

Illustrative walk through the churn tree from the quickstart.

SELECT rvbbit.save_tree('churn', rvbbit.branch(
  'Does this customer show meaningful churn risk?',
  yes := rvbbit.branch(
    'Is an unresolved service problem the main concern?',
    yes := rvbbit.leaf('service intervention'),
    no := rvbbit.leaf('relationship review'),
    threshold := 0.7),
  no := rvbbit.leaf('routine follow-up')));

SELECT customer_id,
       (rvbbit.run_tree('churn', recent_messages)).label
FROM customer_contexts;

Sugar, when you want it

DuckDB 2.0's grammar extension API lets rvbbitduck add real words: MEANS, ABOUT, NEAR, ABOVE, SUPPORTS, CONTRADICTS, IMPLIES, SEMANTIC CASE, CREATE DECISION TREE and DECIDE name FOR state. The transform returns a normal DuckDB AST node, so there is no new physical operator.

It is off until you run SET active_grammar_extensions = ['rvbbit']. The new words are unreserved, so column names keep working. Read the syntax notes, including the forms that did not fit.

SET active_grammar_extensions = ['rvbbit'];

SELECT * FROM tickets
WHERE body MEANS 'customer wants to cancel' ABOVE 0.8;

CREATE DECISION TREE churn AS
  BRANCH 'Does this customer show meaningful churn risk?'
    YES 'retention'
    NO 'routine follow-up';

SELECT (DECIDE churn FOR recent_messages).label
FROM customer_contexts;
SELECT SEMANTIC CASE ON body
         WHEN 'The customer explicitly asks to cancel' ABOVE 0.8 THEN 'retention'
         WHEN 'The request is about billing' THEN 'finance'
         ELSE 'triage'
       END
FROM tickets;

Embeddings you can JOIN

embed returns a FLOAT[]at 1024 dimensions by default, with a cache and per-chunk dedupe. Cast it and use DuckDB's own NEAREST and array_cosine_similarity. nearest_label maps text to the closest of your labels.

embed_index fills a FLOAT[N] column and, when the vss extension is loaded, creates a cosine HNSW index. Otherwise it tells you, and NEAREST stays a brute-force join.

SELECT d.text
FROM (
  SELECT rvbbit.embed('cancel my subscription')::FLOAT[1024]
    AS embedding
) q
JOIN docs d
NEAREST 1 BY SIMILARITY
  array_cosine_similarity(q.embedding, d.embedding);
SELECT rvbbit.nearest_label(
  body, ['cancel the subscription', 'thanks for the help'], ['billing', 'praise'], 'other')
FROM tickets;

SELECT rvbbit.embed_index('tickets', 'body');

Aggregates, vision and receipts

Collection operators are real GROUP BY aggregates. A group keeps at most 48 distinct texts, and larger groups are reduced in chunks. locate returns a box for what you describe in an image. And spend() is the exact sum of ledger().

A repeated question is a cache hit, which costs 0 and still gets a ledger row. Your API key is never stored there.

SELECT region, rvbbit.classify_collection(body, 'billing,shipping,other')
FROM tickets
GROUP BY region;
SELECT rvbbit.truth('please cancel the appointment', 'the customer wants to cancel');
SELECT rvbbit.truth('please cancel the appointment', 'the customer wants to cancel');
SELECT http_requests, cache_hits, cost FROM rvbbit.spend();
SELECT (rvbbit.locate('[' || rvbbit.image_part(photo) || ']', 'the visible damage')).top
FROM listings;

How it works

One extension between your rows and the model.

HTTP runs inside the extension through libcurl. No sidecar, no gateway, and LOAD rvbbit does not need httpfs.

  1. 1

    Your SQL

    Plain functions, or opt-in words that desugar to them.

  2. 2

    rvbbit

    Dedupes a vector, checks the cache, batches the rest, and walks only the tree path taken.

  3. 3

    OpenRouter

    Or your own GPU, through one provider resolver.

  4. 4

    Rows and a receipt

    Results in your query. A ledger row for every call.

Batching

Each vector dedupes identical bodies and posts them together, bounded by rvbbit_max_concurrency (default 8). Requests share a connection cache and ask for HTTP/2.

Retries

429 and 5xx retry with backoff (rvbbit_max_retries, default 3), honoring Retry-After up to 5 seconds.

Caching

An in-memory LRU of 10000 entries by default. Set rvbbit_cache_path and judgments and trees persist in a DuckDB file.

Fused decisions

Inside one chunk, questions about the same state share a single decisions request, up to 8. A rejected fused call is sent again as separate requests.

Honest errors

A connection failure or a non-retryable 4xx raises. It never silently becomes NULL.

Evidence boundary

Decision calls prefix the same evidence boundary Calliope uses on every non-box question.

Default models

Decisions
typesafe/jev-1.13 via POST /api/alpha/decisions, contract clover-decisions-v1
Embeddings
mongodb/voyage-4, 1024 dimensions by default, batches of 64
Chat operators
set with rvbbit_chat_model or the secret's CHAT_MODEL, with reasoning off unless rvbbit_reasoning says otherwise

Bring your own GPU

OpenRouter is the default. Every POST goes through one resolver: a bare id stays on OpenRouter, name:model uses a provider secret, and http://host:port/model is a raw address. That is the shape for a vLLM or llama.cpp server.

API 'openai' has no decisions endpoint unless you add DECISIONS true. Without it, a decision or locate call names the provider and says a chat structured-output fallback is not implemented yet. ledger() adds provider and base_host.

CREATE SECRET gpu (
    TYPE rvbbit_provider,
    BASE_URL 'http://3090:8000',
    API 'openai',
    KEY 'optional',
    MAX_CONCURRENCY 2
);
SET rvbbit_chat_model = 'gpu:llama';
SET rvbbit_embed_model = 'gpu:bge-m3';
SELECT rvbbit.embed('cancel the order');

Model Context Protocol

Any MCP server, as a SQL table.

Primitives and grammar, inside the extension. HTTP (streamable, plus legacy SSE) and stdio both run in-process. The secret type is rvbbit_mcp, not duckdb_mcp's attach form.

mcp.sql
CREATE SECRET gh (TYPE rvbbit_mcp, TRANSPORT 'http', URL 'https://mcp.example/mcp', TOKEN '...');
SELECT rvbbit.mcp_attach('gh', 'gh');
SELECT rvbbit.mcp_text('gh', 'search', '{"q":"cancel"}');

Guardrails you can set from SQL

  • Reads can be cached. Mutations are never cached, and are refused inside an explicit transaction unless rvbbit_mcp_allow_in_txn is set.
  • rvbbit_mcp_max_mutations caps mutations per query (default 100).
  • rvbbit_mcp_policy allows or denies server tools for read and mutate, as JSON.
  • Stdio commands must be absolute paths listed in rvbbit_mcp_allowed_commands. Empty denies all stdio.
  • A front door should deny by default, then SET lock_configuration = true.
  • Pass an idempotency key with WITH IDEMPOTENCY. Tokens and env values are not stored in the audit log.

Read or mutate?

A tool is a read when rvbbit_mcp_read_toolsmatches it, else when the secret's READ_TOOLS does (and MUTATE_TOOLS does not), else when the server sent readOnlyHint. No hint means a mutation. mcp_tools() shows the choice in mode and source.

Rows from any response

mcp_rows calls the tool once at bind and freezes the columns. An array, or an object that holds one array, becomes columns. An object with no array is one row. Otherwise each content block is a row.

Macros per tool

mcp_wrap creates a scalar and a table macro per tool in mcp_<server>. A mutation returns STRUCT(result, is_error), matching CALL MCP. The mode and policy still apply when the macro runs.

Function reference

Everything lives in the rvbbit schema.

So nothing collides with other extensions. apart, for example, already owns an unqualified decision_tree. The full catalog has arguments, defaults, return types and an example for each function, and CI fails if it drifts from duckdb_functions().

Decisions

  • rvbbit.truth
  • rvbbit.truth_score
  • rvbbit.choose
  • rvbbit.decide
  • rvbbit.truth_question
  • rvbbit.choice_question
  • rvbbit.semantic_case
  • rvbbit.prompt
Settings22 session settings
SettingDefaultRole
rvbbit_transportlivemock answers locally. Tests use this.
rvbbit_max_concurrency8In-flight HTTP cap for OpenRouter, and the fallback when a provider secret omits MAX_CONCURRENCY. Each provider has its own cap.
rvbbit_max_retries3Extra attempts after 429 or 5xx.
rvbbit_retry_base_ms200First backoff. Later attempts double it, capped at 2s.
rvbbit_cache_size10000LRU entries.
rvbbit_cache_pathemptyDuckDB file for judgments and trees.
rvbbit_base_urlemptyOverrides the OpenRouter origin. Named providers and raw addresses keep their own origin.
rvbbit_decision_modelemptyJev model. A bare id stays on OpenRouter. name:model uses a provider secret. http://host:port/model is a raw address.
rvbbit_chat_modelemptyChat model. Same three forms as rvbbit_decision_model.
rvbbit_embed_modelemptyEmbeddings model. Same three forms. Empty uses the secret or mongodb/voyage-4. voyageai/voyage-4 is rewritten only on OpenRouter.
rvbbit_vision_modelemptylocate's model. Empty keeps typesafe/jev-1.14 on OpenRouter. Same three forms.
rvbbit_embed_dim00 uses the secret or 1024. Any other value is the list length embed returns and the dimensions field sent to OpenRouter.
rvbbit_reasoningdisableddisabled sends {"enabled": false}. none, minimal, low, medium, and high send {"effort": ...}. enabled turns reasoning on.
rvbbit_timeout_sec60Timeout for one POST. Connect timeout is 10 seconds.
rvbbit_tls_verifytrueSet false only for a local certificate, as scripts/transport_smoke.sh does.
rvbbit_ignore_envfalseIgnore OPENROUTER_API_KEY.
rvbbit_mcp_allowed_commandsemptyExact absolute paths allowed to spawn for stdio MCP. Empty denies all stdio. lock_configuration freezes it.
rvbbit_mcp_policyemptyJSON, or a path to JSON, allowing or denying server tools for read and mutate. Empty allows every attached tool. lock_configuration freezes it.
rvbbit_mcp_max_mutations100MCP mutations allowed in one query. lock_configuration freezes it.
rvbbit_mcp_allow_in_txnfalsePermit a mutation inside BEGIN. lock_configuration freezes it.
rvbbit_mcp_server_concurrency4In-flight HTTP calls per MCP server. stdio stays at one. lock_configuration freezes it.
rvbbit_mcp_read_toolsemptyJSON object of server name to tool globs, such as {"gh":["read_*","list_*"]}. A match forces a read. lock_configuration freezes it.

Install

Build it today. Community install is next.

Pinned to DuckDB 2.0.1 through the official C++ extension template. The community descriptor draft lives in the repo, and is not in duckdb/community-extensions until that submission is approved.

Available now

Build from source

git clone --recurse-submodules https://github.com/ryrobes/rvbbitduck.git
cd rvbbitduck
sudo apt-get install -y ninja-build build-essential python3 libcurl4-openssl-dev pkg-config   # once
GEN=ninja make release

./build/release/duckdb links rvbbit, so LOAD rvbbit works there. A stock DuckDB binary loads the shared library by path:

LOAD 'build/release/extension/rvbbit/rvbbit.duckdb_extension';

Coming soon

Community extension

After the submission is accepted, a DuckDB 2.0.1 build installs it with:

INSTALL rvbbit FROM community;
LOAD rvbbit;
SELECT rvbbit.version();

The draft targets linux_amd64, linux_arm64, osx_amd64, osx_arm64 and windows_amd64. WASM builds are not part of it. Windows builds OpenRouter HTTP, and MCP on Windows raises and names the reason.

Then, a first query

Create an OpenRouter secret, or export OPENROUTER_API_KEY. Want to look around without a key? SET rvbbit_transport = 'mock' answers locally.

CI never calls OpenRouter. scripts/live_smoke.sh exits immediately unless OPENROUTER_API_KEY is set, and the Linux workflow fails if that variable is present, so a secret cannot be spent by accident.

LOAD rvbbit;
SET rvbbit_transport = 'mock';   -- no key needed, nothing leaves the process
SELECT rvbbit.version();

SELECT rvbbit.truth('please cancel the appointment', 'the customer wants to cancel');

How it differs

Other Jev extensions, and what they leave out.

What you get here that those do not: a lazy tree with prior-judgment context, evidence binding, an audited path, and wave batching across the rows of a vector. SQL that composes in WHERE, JOIN and GROUP BY. And opt-in words that desugar to those functions.

ExtensionWhat it isWhat it does not do
decidedecision, decision_prob, decision_choice, decision_score over OpenAI Decisions / Jev. Small batches, low concurrency.No trees, no grammar, no shared chat operators.
jevjev, jev_prob, jev_choice, jev_score, jev_eval.Scalar judgments only.
querio_jevOpenRouter, a disk cache, dedupe, httpfs.No lazy tree, no path trace.
typed_aityped_is, typed_pick, typed_score, typed_box, budgets.No tree walk.
anofox_decideMany backends, including ONNX, plus calibration metrics.No OpenRouter tree language.
dcA fast path and a slow path.No grammar and no decision tree.
aiA wide LLM suite, including ai_jev / ai_decide, many providers.Not a port of rvbbit's tree contract.
flockllm_complete, filter, reduce, embeddings, and MODEL/PROMPT objects.Objects are prompts, not a lazy judged tree.
apartA numeric affine decision_tree.Name collision only. Different function, different schema.

Straight talk

What is stubbed, and what is next.

This is a young extension. These are the edges in the README today, so you do not find them by surprise.

  • rowset and query operator shapes are listed in the catalog and raise when called. Dimension operators return VARCHAR[] rather than Postgres SETOF.
  • Heterogeneous takes.nodes are stored but not executed. Homogeneous factor takes run, with vote, first_valid, evaluator and consensus.
  • Without vss loaded, NEAREST stays a brute-force join. With it, embed_index creates the cosine HNSW index.
  • A chat structured-output fallback is not implemented. A provider with API 'openai' has no decisions endpoint unless you add DECISIONS true.
  • knn_text, topics, dedupe_groups and diff take VARCHAR[] and cap lists at 2000 texts. dedupe_groups is pairwise, so it is O(N²).
  • Word operators such as MEANS are a dedicated expression alternative, not a new comparison precedence level. The function form stays the contract where the grammar cannot reach.
  • A per-call model := on catalog operators and aggregates is planned. Today they follow the session setting.
  • FROM MCP arguments are constants: a join on the result works, a lateral reference to another row's column does not.

On the list

  1. Heterogeneous takes.nodes execution.
  2. HNSW persistence and tuning options such as M and ef_construction.
  3. A real precedence slot for word operators, if the grammar API grows.
  4. Live checks beyond CI, and a WASM transport behind LivePostMany.

FAQ

Questions, answered from the README.

Do I need Clover, Hutch or any gateway?

No. The extension makes its own OpenRouter calls through libcurl. By default it posts to https://openrouter.ai. You would only point rvbbit_base_url at Hutch or another gateway if that gateway serves /api/alpha/decisions, /api/v1/chat/completions and /api/v1/embeddings.

Which key does it need?

An OpenRouter key. Create a secret with CREATE SECRET (TYPE openrouter, KEY '...') or set OPENROUTER_API_KEY. If both exist, the secret is used first: the environment variable is the fallback when no secret is present.

Do I need httpfs?

No. HTTP is the extension's own bundled libcurl client, which shares a connection cache and asks for HTTP/2. LOAD rvbbit works without httpfs.

Can I try it without spending anything?

SET rvbbit_transport = 'mock' answers locally without OPENROUTER_API_KEY. The extension's test suite runs on that transport and never leaves the process. A live call needs a key.

Is the grammar on by default?

No. Everything works as plain functions. MEANS, ABOUT, SEMANTIC CASE, CREATE DECISION TREE, DECIDE, FROM MCP and CALL MCP are opt-in sugar: SET active_grammar_extensions = ['rvbbit']. They desugar to the same functions.

How do I keep an eye on cost?

SELECT * FROM rvbbit.ledger() has one row per call and per cache hit. rvbbit.spend() totals requests, cache hits, tokens and cost. Cache hits cost 0. Calls to other providers cost 0 unless the response reports usage.cost.

What happens when a request fails?

429 and 5xx responses retry with backoff and honor Retry-After up to 5 seconds. A connection failure raises, and so does a non-retryable 4xx such as 401 or 403. Neither comes back as NULL.

Can MCP tools change things?

Yes, mutations are first-class. They are never cached, they are refused inside an explicit transaction unless you set rvbbit_mcp_allow_in_txn, and rvbbit_mcp_max_mutations caps them per query. A tool counts as a read only when your settings or the server's readOnlyHint say so. No hint means a mutation.

Does it run in the browser or on Windows?

There is no WASM build yet: the native client is libcurl. Windows builds support OpenRouter HTTP, and MCP on Windows raises with the reason. The community draft targets linux_amd64, linux_arm64, osx_amd64, osx_arm64 and windows_amd64.

Is it published as a community extension?

Not yet. The descriptor draft is in the repo and is not in duckdb/community-extensions until its submission is approved. Until then, build it from source.

Put semantic judgment in your next query.

Open source, MIT, and one OpenRouter key away. Star it, build it, and file what breaks.

rvbbitduck is MIT licensed. Copyright 2026 Ryan Robitaille. It ports the decision core of rvbbit 1.2.3.