Understanding Jev: System One AI Judgment Primitives for Production Software

Understanding Jev: System One AI Judgment Primitives for Production Software

Somewhere in your codebase there is a function that sends a support ticket to a language model with a long prompt and then tries to read the answer. It asks for a category, a priority and a one-line reason, and it parses the reply with a regular expression that looks for "Category:" at the start of a line. For months it works. Then a provider updates the model, the answer starts with "Sure! Here is the classification", the regex matches nothing, and every ticket lands in the default queue until someone notices the backlog. The fix is another sentence in the prompt. Nobody is sure which of the existing forty sentences it contradicts.

This is the prompt-and-parse loop, and most teams who ship AI features write it at least once. The model is capable; the problem is the shape of the interface. A free-text answer is being used as a typed value, and the application has no contract with the thing producing it. This article is about a different shape: small models that answer one bounded question per call and return a typed result with a probability, so that the workflow stays in code where you can read it, test it and change it. We will use the vocabulary of Jev, a System One model from TypeSafe, as the running example, while keeping the ideas portable.

1. Why the prompt-and-parse loop rots

The loop has four weak joints, and each fails in its own way.

  1. Format drift. The model is asked for a format and usually complies. "Usually" is the problem. A changed model version, a longer input or one unusual ticket can add a preamble, change a label's capitalisation or wrap the answer in markdown. The parser breaks, or worse, accepts the wrong thing.
  2. Entangled concerns. One prompt asks for category, priority, sentiment and a reply draft. Improving one instruction shifts the others. There is no unit you can test alone.
  3. Hidden uncertainty. A free-text answer carries no honest measure of how sure the model was. You get "High" whether the ticket was clear or a coin flip. Teams then bolt on a second call asking the model to rate its own confidence, which is another free-text answer with the same problem.
  4. Cost and latency on the critical path. Generating a paragraph to extract a single label spends output tokens on prose you will throw away, and generation time is paid by the user waiting for the next step.

None of these mean the model is bad at reading tickets. They mean the interface asked it to do two jobs: judge, and then format the judgment as text for a parser to undo. A judgment primitive removes the second job by making the typed value the output.

2. System 1 and System 2 as an engineering split

The vocabulary comes from a well-known framing in cognitive psychology: a fast, automatic mode of judgment and a slow, deliberate mode of reasoning. Applied to software, the analogy is loose but useful. Many decisions inside an application are fast judgments over text: is this message urgent, which team owns it, does this paragraph answer the question, how relevant is this document. They need a good read of language and a small, structured answer. They do not need a chain of thought.

Other tasks are genuinely deliberate: planning a multi-step change, writing a long explanation, debugging an unfamiliar system. Those benefit from larger models, longer reasoning and tool use.

The engineering split is this: let code be the orchestrator, let small judgment models answer bounded questions, and call the large reasoning model only where deliberation is needed. The orchestration, which is the control flow, retries, thresholds and permissions, belongs in ordinary code. It is the part of the system you most want to be reviewable, diffable and deterministic. The model supplies one bounded judgment per call. The word deterministic describes your control flow around the model, not the model itself: the same judgment call can still return slightly different probabilities across model versions, which is why you evaluate rather than assume.

3. The three primitives and what each is for

Jev's programming model has three question types. The choice of primitive is the main design decision, so it is worth understanding what each returns and where each goes wrong.

Primitive Question shape What comes back Use it for Common trap
Choice Which one of these defined options? A distribution over the options Routing, picking a handler, normalising a value to a known list Overlapping options that split the distribution
Noul Does this condition hold? A probability of yes Independent flags: urgent, contains a refund request, mentions a deadline Using one Choice where several flags can be true together
Score How much of a described quality is present? A probability-weighted position on ordered levels Relevance, severity, clarity, risk, any degree Vague level descriptions that no two people would apply the same way

Choice: one of a defined set

A Choice picks among options you define. The returned distribution is more useful than the winner alone. A result of 0.92 for one option and 0.03 for the rest means something different from 0.48 and 0.44, even though both name a winner. Code can treat the first as routable and the second as a prompt to ask a person or a bigger model. Options should be mutually exclusive and exhaustive enough, usually with an explicit "other" so the model has somewhere honest to go.

Noul: whether a condition holds

Noul answers a yes/no question as a probability. When several conditions can be true at the same time, ask one Noul per condition. That is the point of the primitive: a ticket can be urgent, mention a refund and come from an enterprise customer all at once, and forcing those into a single multiple-choice answer either loses combinations or invents combined labels like "urgent_refund_enterprise".

Score: how much, on a scale you describe

Score places the input on ordered levels that you write out, such as "no impact, minor inconvenience, blocks one user, blocks many users". The result is a probability-weighted position, which gives you a smooth value you can compare and combine. The quality of a Score is bounded by the quality of the level descriptions: if a human reviewer cannot tell levels two and three apart, neither can the model.

4. State: put the evidence in front of the model

The input to a judgment is the state: the source text plus whatever facts the decision needs. Three habits make this layer reliable.

  • Inline everything the answer depends on. The ticket text, the customer's plan, the policy excerpt, the current time if urgency depends on it. A model cannot consult what it was not shown, and anything it infers from missing context is a guess.
  • Put the meaning in the question. Question identifiers are for your code to match results back to calls. They are not sent as context. "Is this ticket about a charge the customer did not expect?" is a question; q_billing_3 is a label for your own bookkeeping.
  • Do not ask the model for what code can compute. Account age, order count and whether a date is in the past are lookups. Compute them and include the result as a fact. Judgment is for the parts that require reading language.

Independent questions over the same state are asked together in one request. They run in parallel and do not see each other's answers, so there is no cross-contamination, and the wall-clock cost of adding another independent question is small compared with a second round trip. A second request is justified only when an earlier answer is required to build the next state, for example when a retrieval step has to run before relevance can be scored.

5. What confidence means and what it does not

Every typed result comes with a way to see how decisive it was. Treat it as a signal about this one answer: how peaked the distribution is. Three misreadings cause most of the trouble.

  1. Confidence is not accuracy. A model can be decisively wrong. The only way to learn how often "0.9" is right on your data is to label a sample and measure. Until then, a threshold is a hypothesis.
  2. Confidence is not permission to act. A high probability that a refund request is legitimate does not authorise issuing a refund. Actions have their own gates: policy limits, approvals and audit logs, all in code.
  3. Confidence does not transfer between domains. A threshold tuned on English billing tickets says little about German legal notices. Recalibrate when the input distribution changes, and be suspicious of numbers copied from someone else's example.
Calibrate before you trust. Collect a few hundred real inputs with human labels, run the judgment, and plot how often each confidence band is correct. Choose thresholds from that curve and the cost of each kind of error, then keep the labelled set as a regression test for every future change.

6. A worked example: triaging a support ticket

Return to the opening scenario and replace the single prompt with a small set of bounded questions. The code below uses a stand-in client defined in the snippet, so the control flow is runnable-looking and independent of any vendor SDK. Substitute the real client you use and check its current documentation for request shapes.

from __future__ import annotations
import asyncio
from dataclasses import dataclass
from typing import Protocol, Sequence

class Judge(Protocol):
    """Illustrative client: map this onto the judgment client you actually use."""
    async def choice(self, *, state: str, question: str, options: Sequence[str]) -> dict[str, float]: ...
    async def noul(self, *, state: str, question: str) -> float: ...            # P(yes)
    async def score(self, *, state: str, question: str, levels: Sequence[str]) -> float: ...  # 0..1

TEAMS = ("billing", "outage", "account_access", "how_to", "other")
SEVERITY = ("cosmetic", "annoying", "blocks_one_user", "blocks_many_users")

@dataclass
class Triage:
    team: str
    needs_human: bool
    priority: float
    reason: str

def render_state(ticket: str, plan: str, open_incident: bool) -> str:
    return (
        f"Ticket text:\n{ticket}\n\n"
        f"Customer plan: {plan}\n"
        f"Company has an open incident right now: {open_incident}\n"
    )

async def triage(judge: Judge, ticket: str, plan: str, open_incident: bool) -> Triage:
    state = render_state(ticket, plan, open_incident)

    team_d, wants_refund, threatens_churn, severity = await asyncio.gather(
        judge.choice(state=state, options=TEAMS,
                     question="Which team should own this ticket?"),
        judge.noul(state=state,
                   question="Is the customer asking for money back?"),
        judge.noul(state=state,
                   question="Does the customer say they may cancel or leave?"),
        judge.score(state=state, levels=SEVERITY,
                    question="How much of the customer's work is blocked by this problem?"),
    )

    team, p_team = max(team_d.items(), key=lambda kv: kv[1])
    second = sorted(team_d.values(), reverse=True)[1]

    # Weights and combination live in code, where they are reviewable and testable.
    priority = 0.6 * severity + 0.25 * threatens_churn + 0.15 * (1.0 if plan == "enterprise" else 0.0)

    ambiguous = (p_team - second) < 0.25
    needs_human = ambiguous or wants_refund > 0.5   # money decisions are never automatic
    reason = "ambiguous owner" if ambiguous else ("refund request" if wants_refund > 0.5 else "routine")
    return Triage(team="other" if ambiguous else team, needs_human=needs_human,
                  priority=round(priority, 3), reason=reason)

Read the function as a specification. Each model call has a single job with a typed result. The combination of severity, churn risk and plan tier into a priority is arithmetic you can argue about in a code review. The rule that anything touching money needs a person is a line of code, not a sentence the model may or may not honour. If the model is replaced tomorrow, the unit tests for triage still describe the intended behaviour, and the labelled set tells you whether the new model preserves it.

7. Decomposition shapes that keep recurring

Once you think in primitives, a handful of shapes cover a large share of real features. They are starting points to adapt, not templates to force.

  • Route and fill arguments. One Choice picks the handler. Companion questions fill the handler's typed parameters, such as which account, which date range, which severity.
  • Select, don't generate. Code finds the candidates with a regex, a retrieval query or a database list. A question then picks or normalises among them. The model never invents a value that must exist in your system, which removes a whole class of hallucinated identifiers.
  • Find and judge evidence. Retrieve candidates, score relevance, keep what clears a bar. The bar is tuned on labelled data, and the retrieval step stays swappable.
  • Composite scoring. One Score per independent dimension, with the weights and the combination in code. This is easier to audit than a single score for "overall quality" with an opaque rubric.
  • Verify and escalate. Check one claim against its evidence. Send low-confidence or failing cases to a person or to a larger model. The cheap judgment filters; the expensive reasoner sees only what needs it.
  • React to changing state. Keep goals and observations in code, ask one bounded question per step, and re-check freshness before acting on an answer that may be stale.
Property Prompt-and-parse loop Typed judgment primitives
Output contract Text that a parser must interpret Typed result with a distribution
Unit of testing The whole prompt One question, with a labelled set
Uncertainty Implicit, or a self-reported number Explicit, read from the distribution
Where the workflow lives Inside the prompt In ordinary code
Effect of swapping the model Unpredictable, re-prompt and hope Re-run the labelled set, adjust thresholds
Fit for open-ended generation Good Not its job

8. Failure modes and when not to use this

Judgment primitives are strong at bounded questions over text and weak or wrong elsewhere. Keep these limits in view.

  • Open-ended generation. Drafting a reply, summarising a thread, writing code. A distribution over a closed set cannot express them. Use a generative model, and use primitives around it to route or check.
  • Deep multi-step reasoning. Questions that need arithmetic over several facts, long chains of inference or consulting tools belong to a reasoning model with tools. Break the problem so that the primitives answer the language-understanding steps and code does the arithmetic.
  • Facts the model was not shown. Whether an order shipped, whether a user is in a region, whether a feature flag is on. These are lookups, not judgments.
  • Vague questions. "Is this good?" has no stable answer. Rewrite until two reviewers would agree on most examples, then check agreement on a sample before involving the model.
  • High-stakes decisions without a human or a hard rule. A judgment can prioritise and route, but decisions with legal, financial or safety weight need explicit rules and review around them.
  • Silent distribution shift. A new product line, a new language or a viral incident changes what tickets look like. Monitor the confidence distribution and the share routed to humans; a sudden shift is an early warning even before you have fresh labels.

9. Decision checklist, common mistakes and what to do Monday

Use this checklist when deciding whether and how to introduce a primitive into a feature.

  1. Can the decision be stated as a closed set, a yes/no condition or a degree on a described scale?
  2. Is every fact the answer depends on available in the state, and is anything computable computed in code rather than asked?
  3. Are independent questions batched into one request, and dependent ones sequenced only where an earlier answer is truly needed?
  4. Do you have labelled examples, and does a script report accuracy and calibration per question?
  5. Are thresholds, weights and permissions in code, with a safe default when the model is slow, wrong or unavailable?
  6. Does every irreversible action sit behind its own gate, independent of the model's confidence?

The most common mistakes: writing a Choice whose options overlap; asking a Choice what should be several Noul flags; leaving the meaning of a question in an identifier; trusting thresholds taken from a tutorial; asking the model to compute something code could look up; and building a multi-stage chain when one request with several independent questions would do.

What to do on Monday

Find one place in your codebase where a language model's text output is parsed to extract a label, a flag or a rating. Write down the possible values. Label a couple of hundred real inputs by hand. Replace the prompt with the matching primitive, run it side by side with the old path, and compare agreement with your labels rather than with each other. Where the new path is as good or better, switch over behind a flag, keep the labelled set in your test suite, and move on to the next parse-and-pray call site.

Short FAQ

Does this replace large language models? No. It takes the judgment steps out of them. Deliberate reasoning and generation stay with larger models, and primitives sit around them as routers, filters and verifiers.

Is the output deterministic? The control flow around it is. The probabilities are a model output, and they can shift when the model changes, so keep a labelled regression set and re-run it on every upgrade.

How do I choose between Choice and several Noul questions? If exactly one answer must hold, use Choice. If several can hold together, ask one Noul per condition.

Where do I find the API details? In the vendor's current documentation. Request shapes, limits and SDK names change faster than the ideas in this article, so treat the snippets here as shape illustrations only.