jevbooks

← All design patterns

Inspection

Contract validation · 验货

A missing part is not a zero

Check that the answers came back complete and sane before anything acts on them, and treat whatever fails as no answer rather than as a zero.

answerΣp = 1c ∈ opts0≤p≤1

The problem

You are building a moderation gate for a chat app. Every message goes to Jev with one question — is this abusive? — and anything above 0.7 is held back. When you read the answer out you added a small safety net: if it is not there, use 0.

One night the response comes back without that answer in it. Your code reads 0, which means "definitely not abusive", and releases the message with total confidence. Nothing alerted anybody. The monitoring is spotless: every request a 200, every response valid, latency normal.

Your instinct is to wrap the line in a try/catch. But there is nothing to catch — the service is healthy and the response is well-formed, it is just missing a piece. That little "use 0" was never a safety net. It was your code inventing an answer the model never gave, and inventing it at the most confident end of the range.

The solution

The inspection pattern says: treat the answers as a delivery, and count the crate before you sign for it. You asked four questions, so four answers should be in there. Three is not a small problem, it is a broken delivery.

Then look at each item. A yes-or-no answer has to be a number between 0 and 1. A pick-one answer has to name something from the list you offered, every option in that list should have a number, the numbers should add up to about 1, and the one it picked should be the largest of them. A pick that is not the largest number is not an answer, it is a bug somewhere upstream.

Whatever fails is not a 0. It is a third thing — "no answer" — and it never enters the decision as a weak probability. It goes down the other road, the one you chose in advance for the times Jev cannot help you.

Ask · Answer · Act

  1. AskPut one chat message — the material Jev is shown, which the docs call the state — in front of it and ask whether the message is abusive.
  2. AnswerNothing. That question is not in the response at all.
  3. ActNo answer is not a zero, so the message does not get treated as safe. It takes the road you wrote down in advance — held back, with a line in the log saying the check never happened.

Where the name comes from

Signing for a delivery. When a part is missing from the crate, the form says "one part missing", not "parts: 0". Write it as a zero and the next person down the line will read it as a machine that was never supposed to have that part.

Use it when

Always. This is not advice, it is the step before the others: the moment anything in your system acts on a number, that number has to be checked first.

Not when

Never — there is no case where skipping the check is safer than doing it. Just be clear about its limit: this checks the shape of an answer, not its meaning. A number can be perfectly well-formed and still say nothing at all.

Projects that do this

  • jev-ultrafast — Browser agent where Jev picks each action and element; LLM only types text.
  • snifftest — Prose linter that flags AI writing tells with countable rules and one judgment model.
  • fast-jev-compaction — Claude Code plugin that prunes context with Jev instead of summarizing.

All projects with this pattern →

Read this code
  • jev-ultrafastjev_ultrafast/model.py:30-45

    Six checks before a single click: the pick is one of the options offered, every option got a number, the numbers add up to about one, and the pick is the biggest of them. Anything else and nothing is clicked.

  • snifftestsrc/jev.ts:384-417

    A missing, non-numeric or out-of-range answer is dropped rather than turned into 0, which is what keeps "never answered" apart from "answered low".

  • fast-jev-compactionsrc/request.ts:66-80

    Anything that is not a finite number throws on the spot, and the tool quietly falls back to its built-in summary instead of guessing.

Show me the code
function noulOf(answers, id) {
  const p = answers[id]?.p;
  return typeof p === "number" && p >= 0 && p <= 1 ? p : null;   // null = no answer, never 0
}
const p = noulOf(answers, "abusive");
if (p === null) return onMissing();      // the road you chose in advance, not the decision
if (p >= 0.7) return hold(message);
How jevbooks recognises it

How do we know a project does this? We put one question about its README to Jev and it returns a percentage; the higher, the more it looks like it. If you copy the question, copy one thing: ask whether the text mentions this one concrete thing, never whether the project is good.

questions.json · sent for every README
{
  "contract-validation": {
    "type": "noul",
    "instructions": {
      "what": "Does the text describe checking Jev's answer shape before acting, such as choice in candidates, probabilities summing to one, or discarding out-of-range values?",
      "not_for": "Trusting the response as-is."
    },
    "criteria": {
      "true": "The text explicitly describes this. One sentence is enough; other content does not cancel it.",
      "false": "The text does not describe this."
    }
  }
}

Build this with Jev →