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.
| Pattern | What it does | Benefits | In Dcision | Template |
|---|---|---|---|---|
| Speculative fan-out | Ask every question the flow might need in one call and let rules decide which answers matter. | Cost, speed | All questions in one decision; and conditions gate the speculative answers. | ticket-triage |
| Confidence-gated routing | Use confidence as a second axis: the answer says what, confidence says whether to act. | Reliability, safety | minConfidence per question and rules on: "confidence", one threshold per action. | voice-banking |
| Composite scoring | Break a judgment into atomic scores and combine them with weights you control. | Cost, reliability, speed | One question per dimension and composites, usable in rules. | resume-screening |
| Intent routing | Classify each request in one fast call and send it to the cheapest capable handler. | Cost, speed | One 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
| Feature | Useful for |
|---|---|
| Up to 64 questions per decision, answered in one call | fan-out, composite scoring, intent routing |
Policy rules with up to 5 and conditions, first match wins | fan-out, confidence-gated routing, intent routing |
minConfidence per question and rules on confidence | confidence-gated routing |
Weighted levels of score questions (scores, rules on: "score") | fan-out, intent routing |
Composites, returned in composites and usable in rules | composite scoring |
The reserved other option and the fallback action | intent routing, confidence-gated routing |
onEngineError: "fallback" — a safe action when the engine fails | every 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:
| Pattern | Detected when the decision has… |
|---|---|
| Speculative fan-out | 4 or more questions, or 3 or more with a rule whose conditions use different fields |
| Confidence-gated routing | a question with a minimum confidence, or a rule on confidence |
| Composite scoring | at least one composite |
| Intent routing | a 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.
Executions and usage
Every run is logged with its version, action reason, confidence and — if you allow it — input and output. Find executions, read usage and know how long logs are kept.
Speculative fan-out
Ask every question a flow might need in one call — Jev answers them in parallel — and let AND rules and your code decide which answers matter. Built on the Support Ticket Triage template.