decision trees you can curl

Extract, then decide, then route

Pull the facts out of the text first, then ask a small decision model the questions that need judgment, then let ordinary SQL or a wired-up tree apply your rules. One large prompt that tries to do all three is harder to trust and harder to fix.

Published November 22, 2026. Live demos: /scam, /router, /product, /sba. Scores: /models, as of November 29, 2026, 10:56 PM, America/New_York.

The short answer

Most “should we refund this?” or “is this a scam?” problems are a mix of lookup, judgment and policy. The amount on the invoice is a fact. Whether the customer is asking for money back is a judgment. Whether a claim under $25 is auto-approved is a rule you already know. If you stuff all of that into one prompt, a wrong answer arrives as a single probability. You cannot tell which part failed.

TypeSafe made this point directly on November 3, 2026, in Don’t Call It a Decision Model: Jev should make small judgments; your code should make the decision. The same split works in SQL. Extract structured fields. Ask one decision question at a time. Branch with a CASE, a threshold, or a tree you can read.

A concrete path

Take an inbound email. First, read the fields you actually need: a claimed sender, the domains in the links, a dollar amount, a date. If a required field is missing, stop and say so. Do not guess. Then ask a decision model a narrow question: is this an account alert, a delivery notice, a prize, a bill, or a newsletter? Then apply the rule for that kind: a link domain that does not match the claimed sender is enough to be careful, even if the prose is polite.

That is the scam check on che.sh. An extract step reads the message; a seven-way question sorts the kind; one follow-up question per kind applies that kind’s rule. The answer names the reason. The same shape shows up in SBA intake (illustrative screening, not lending advice) and in the product page check: find name, price, rating and review count, then decide. /router is the hop in front of those demos: one classification, then the matching tree runs on the same input.

How warehouses compose the same idea

This is not unique to us. Databricks documents ai_extract and ai_classify as functions that can take VARIANT output from another AI function, such as ai_parse_document (ai_extract, ai_classify). ai_decide can ask several questions in one call, as long as the question list is a constant. Snowflake splits the work across AI_EXTRACT and AI_CLASSIFY or AI_FILTER. BigQuery leans on output_schema so a generate call returns typed JSON you can query.

Those compositions work. They also stay inside that warehouse, and the “tree” is often still a JSON argument or an application loop rather than a typed function the query planner treats like any other. That is the gap we care about.

How we handle it with rvbbit and che.sh

On che.sh, an extract step is a node in the tree. It calls rvbbit.clover_extract_fields. Found values become {placeholders} in later questions; a required field that is missing takes the missing branch and is never invented. Decision questions then run as rvbbit.branch or rvbbit.choice_branch, and the whole thing is rvbbit.decision_tree over a body column. Press s on a tree to see the SQL. A shortened form:

WITH inputs(id, body) AS (VALUES (1, 'We want $250,000 for a second oven.')),
x_x AS (
  SELECT i.id, rvbbit.clover_extract_fields(i.body,
    '{"loan_amount":{"type":"number","instructions":"requested loan amount in dollars"}}'::jsonb,
    '') AS f
  FROM inputs i
)
SELECT i.id, d ->> 'label' AS decision, d -> 'path' AS why
FROM inputs i JOIN x_x USING (id),
     LATERAL (SELECT CASE
       WHEN (x_x.f #>> '{answers,loan_amount,value}') IS NOT NULL
        AND (x_x.f #>> '{answers,loan_amount,confidence}')::float8 >= 0.5
       THEN rvbbit.branch(
              replace('Is {loan_amount} over 350000 dollars?',
                      '{loan_amount}',
                      x_x.f #>> '{answers,loan_amount,value}'),
              rvbbit.leaf('large'), rvbbit.leaf('small'), 0.5)
       ELSE rvbbit.leaf('ask for the loan amount')
     END AS t) tree,
     LATERAL rvbbit.decision_tree(i.body, tree.t, 16) AS d;

The export is close to che.sh, not identical: it reads every extract step for every row, and the decision model sees the filled-in text, while che.sh also passes found fields as evidence. For a reusable pipeline, rvbbit can wrap the same chain as one typed function. A Cascade is just an operator whose op_steps are set on rvbbit.create_operator: extract, then a specialist or decision step, then a check, still called as one typed function (the Cascades docs use a review_risk example). Documented at rvbbit.ai/docs/cascades/ and semantic SQL. Every model-backed step can write a row to rvbbit.receipts.

You can also start cheaper than a model, then escalate. rvbbit.semantic_case embeds the text and the candidate labels and picks the closest branch, with no LLM. rvbbit.extract(text, 'what to find') is a seeded extractor when you want a single literal value. Both are documented at semantic functions. che.sh’s own demos use the tree-shaped path above because the editor is a tree, and because a missing field needs an explicit way out.

Try it, then look at the scores

Run che.sh/scam on a made-up message, or che.sh/router on anything and watch it hop. Compare models on the same input. The extract is shared; only the judgments change, which is what you want in a benchmark. Decision-step accuracy, time and cost for those checks are on che.sh/models. As of November 29, 2026, 10:56 PM, America/New_York we have 2928 scored canon runs, about $0.577 in decision-step spend. The extract read is billed separately and is not in those model averages.

FAQ

Why not put the whole decision in one prompt?

A single stuffed prompt is hard to debug. When the answer is wrong, you cannot tell whether a fact was extracted badly, a judgment was off, or a rule was wrong. TypeSafe made the same point on November 3, 2026: the model should make small judgments, and your code should make the decision.

How does che.sh do extract-then-decide?

An extract step calls rvbbit.clover_extract_fields. Required fields that are missing take a missing branch and are never guessed. Later questions can use {placeholders}. The tree then asks decision-model questions and your wired-up answers do the routing. The same tree is a function you can curl, or SQL you can run in Postgres.

Where can I try this?

https://che.sh/scam reads a message, pulls out sender and links, then decides. https://che.sh/router classifies an input and hops to the matching demo. https://che.sh/product and https://che.sh/sba extract fields, then route. Press s on any tree to see the SQL.

Do warehouses do this too?

Yes, in pieces. Databricks can pass VARIANT from ai_parse_document or ai_extract into ai_classify or ai_decide. Snowflake has AI_EXTRACT and AI_CLASSIFY as separate functions. The difference is portability and whether the whole chain is one typed function your query planner can see, with cache and receipts.

Sources