Patterns overview

TypeSafe's four architectural patterns — speculative fan-out, confidence-gated routing, composite scoring and intent routing — and how each maps to Dcision features and templates.

Jev answers small, literal questions quickly. Good systems compose many of them. TypeSafe documents four architectural patterns for doing it well, and Dcision turns each one into first-class features of the decision schema — with a template that implements it end to end.

PatternWhat it doesBenefitsIn DcisionTemplate
Speculative fan-outAsk every question the flow might need in one call and let rules decide which answers matter.Cost, speedAll questions in one decision; and conditions gate the speculative answers.ticket-triage
Confidence-gated routingUse confidence as a second axis: the answer says what, confidence says whether to act.Reliability, safetyminConfidence per question and rules on: "confidence", one threshold per action.voice-banking
Composite scoringBreak a judgment into atomic scores and combine them with weights you control.Cost, reliability, speedOne question per dimension and composites, usable in rules.resume-screening
Intent routingClassify each request in one fast call and send it to the cheapest capable handler.Cost, speedOne choice for the intent (with the reserved other), rules for what a person must see.customer-service-router

Why patterns

Every decision is one engine call: Jev reads the state once and answers all the questions in parallel, so adding questions barely changes latency, and Dcision bills one decision per call however many questions it has. The patterns take advantage of that, and of the fact that every answer comes with a calibrated probability:

  • Ask more, not more often — fan-out answers a whole decision tree in one round trip.
  • Act only when sure enough — confidence-gated routing scales the required confidence with the stakes of each action.
  • Keep the math outside the model — composite scoring combines atomic answers with weights stored in the decision.
  • Spend expensive resources last — intent routing sends lookups to code, hard cases to specialist LLMs and the rest to people.

The building blocks

FeatureUseful for
Up to 64 questions per decision, answered in one callfan-out, composite scoring, intent routing
Policy rules with up to 5 and conditions, first match winsfan-out, confidence-gated routing, intent routing
minConfidence per question and rules on confidenceconfidence-gated routing
Weighted levels of score questions (scores, rules on: "score")fan-out, intent routing
Composites, returned in composites and usable in rulescomposite scoring
The reserved other option and the fallback actionintent routing, confidence-gated routing
onEngineError: "fallback" — a safe action when the engine failsevery pattern on a path that must always answer

See Decision schema, Policies and actions and Decision settings.

Patterns in the app

  • Templates opens with a Patterns section: one card per pattern with what it is, when to use it, how to build it in Dcision, its benefits, links to the templates that implement it and to TypeSafe's guide. Below it, All templates shows each template's patterns as badges.
  • New decision lists the patterns of each template next to its number of questions.
  • The editor's Patterns panel, under the decision schema in the Editor tab, says how many of the four patterns the decision uses. Each entry expands to explain the pattern and to show either how this decision uses it (Here) or how to adopt it (Try).

The panel detects a pattern from the schema:

PatternDetected when the decision has…
Speculative fan-out4 or more questions, or 3 or more with a rule whose conditions use different fields
Confidence-gated routinga question with a minimum confidence, or a rule on confidence
Composite scoringat least one composite
Intent routinga choice question with at least 3 options besides other, or a rule on a choice answer

Patterns combine

Most production decisions use more than one pattern. The Lead Qualification template routes the lead to a team (intent routing), escalates when purchase_intent isn't confident enough (confidence-gated routing) and ranks leads with lead_score (composite scoring) — in one call. Templates lists the patterns of every template.

Write questions the engine can answer

Patterns compose answers; each answer still has to be good. Keep questions atomic and literal, keep math and dates in code and send only the state the questions need — see Writing good questions.

On this page